Chào mừng đến với Diễn đàn Dân Kế Toán - Kế toán tổng hợp thực tế.
Trang 1 của 2 12 CuốiCuối
Kết quả 1 đến 10 của 18

Chủ đề: Treeview trong access

  1. #1
    Ngày tham gia
    Aug 2015
    Bài viết
    0

  2. #2
    Ngày tham gia
    Mar 2016
    Bài viết
    15
    Ðề: Treeview trong access

    [flash]http://www.webng.com/soicon/bai1.swf[/flash]

  3. #3
    Ngày tham gia
    Aug 2015
    Bài viết
    0
    Ðề: Treeview trong access

    Để xài treeview, bạn phải chắc chắn rằng trong reference của bạn đã có sẵn ActiveX control Microsoft TreeView control, version 6.0 hoặc hơn.

    Bạn add control activeX này vào form. Sau đó bạn sẽ viết một thủ tục để load dữ liệu vào treeview. VD:

    Private Sub LoadTreeView()
    With TreeView0
    .Nodes.Add , , "K1", "Nut 1"
    .Nodes.Add "K1", tvwChild, "K1a", "Nut con 1a"
    .Nodes.Add "K1", tvwChild, "K1b", "Nut con 1b"
    .Nodes.Add , , "K2", "Nut 2"
    .Nodes.Add "K2", tvwChild, "K2a", "Nut con 2a"
    .Nodes.Add "K2", tvwChild, "K2b", "Nut con 2b"
    .Nodes.Add "K2", tvwChild, "K2c", "Nut con 2c"
    .Nodes.Add "K2", tvwChild, "K2d", "Nut con 2d"
    End With
    End Sub

    Trong đó hai node K1 và K2 là node cha, các node khác có chứa tvwChild là node con ứng với node cha đã xác định ở hto6ng số thứ 1.
    "K1a", "K1b", ... là key của node, dùng nó để sau này ta truy cập một node qua key này.
    "Nut con 1a", "Nut con 1b", ... là nội dung thể hiện của node trên treeview.

    Thông thường, nút con cuối cùng của của một nhánh khi click vào sẽ làm một cái gì đó. Để biết đó có phải là node cuối của nhánh không, ta dùng thuộc tính Children. Nếu nó = 0 thì đây là node cuối của nhánh.

    Ví dụ:
    Private Sub TreeView0_NodeClick(ByVal Node As Object)
    If Node.Children = 0 Then
    MsgBox "Ban da chon node " & Node.Text
    End If
    End Sub

    Trên chỉ là những ví dụ cơ bản để hiểu khái quát về cáchdu2ng treeview, cao cấp hơn thì từ từ. :cheers1:

  4. #4
    Ngày tham gia
    Aug 2015
    Bài viết
    0
    Ðề: Treeview trong access

    Adds a Node object to a Treeview control's Nodes collection.

    Syntax

    object.Add(relative, relationship, key, text, image, selectedimage)

    The Add method syntax has these parts:

    object
    Required. An object expression that evaluates to an object in the Applies To list.
    relative
    Optional. The index number or key of a pre-existing Node object. The relationship between the new node and this pre-existing node is found in the next argument, relationship.
    relationship
    Optional. Specifies the relative placement of the Node object, as described in Settings.
    key
    Optional. A unique string that can be used to retrieve the Node with the Item method.
    text
    Required. The string that appears in the Node.
    image
    Optional. The index of an image in an associated ImageList control.
    selectedimage
    Optional. The index of an image in an associated ImageList control that is shown when the Node is selected.

    Settings

    The settings for relationship are:

    (Constant - Value):
    tvwFirst - 0
    First. The Node is placed before all other nodes at the same level of the node named in relative.
    tvwLast - 1
    Last. The Node is placed after all other nodes at the same level of the node named in relative. Any Node added subsequently may be placed after one added as Last.
    tvwNext - 2
    (Default) Next. The Node is placed after the node named in relative.
    tvwPrevious - 3
    Previous. The Node is placed before the node named in relative.
    tvwChild - 4
    Child. The Node becomes a child node of the node named in relative.
    Note If no Node object is named in relative, the new node is placed in the last position of the top node hierarchy.

    Remarks

    The Nodes collection is a 1-based collection.
    As a Node object is added it is assigned an index number, which is stored in the Node object's Index property. This value of the newest member is the value of the Node collection's Count property.
    Because the Add method returns a reference to the newly created Node object, it is most convenient to set properties of the new Node using this reference. The following example adds several Node objects with identical properties:




    Dim nodX As Node ' Declare the object variable.
    Dim I as Integer ' Declare a counter variable.
    For I = 1 to 4
    Set nodX = TreeView1.Nodes.Add(,,,"Node " & Cstr(i))
    ' Use the reference to set other properties, such as Enabled.
    nodX.Enabled = True
    ' Set image property to image 3 in an associated ImageList.
    nodX.ExpandedImage = 3
    Next I

  5. #5
    Ngày tham gia
    Aug 2015
    Bài viết
    0
    Ðề: Treeview trong access

    [flash]http://www.webng.com/soicon/bai2nho.swf[/flash]

  6. #6
    Ngày tham gia
    Aug 2015
    Bài viết
    0
    Ðề: Treeview trong access

    Đã cập nhật thêm vào flash ở trên. Nhấn vào các flash ở bài trước để xem.

    Có lẽ phần thao tác nhiêu đó là đã đủ để sử dụng treeview rồi.
    <div style="padding-left: 30px">1 - Tạo button "TreeView Control" trong Toolbox.
    2 - Khai báo các node.
    3,4 - Gán 1 thuộc tính (property) bằng câu lệnh (code).
    5 - Gán thuộc tính lúc thiết kế form.
    6 - Tạo 1 hành động khi xảy ra 1 sự kiện (event).
    7 - Tạo ImagesList Control.
    8 - Sử dung ImagesList Control trong Treeview Control.
    ​</div>

  7. #7
    Ngày tham gia
    Apr 2016
    Bài viết
    130
    Ðề: Treeview trong access

    Bài tập nhỏ:
    Tạo 1 form Sổ Cái Tài Khoản có các tính năng như hình dưới.
    [flash]http://www.webng.com/soicon/bai9.swf[/flash]
    Kèm theo: Ban cần 1 số dữ liệu nháp để làm bài tập:
    - 1 số icon dùng để insert vào imageslist. Bạn có thể tìm trên máy của mình các file ảnh có đuôi .bmp hoặc .ico . Chú ý chỉ đưa vào làm icon cho treeview những hình ảnh có kích cỡ nhỏ hơn 24x24 mà thôi.
    Down 1 số ảnh ico mẫu tại đây: www.webng.com/soicon/imagelist.rar

    - Data mẫu down tại đây: www.webng.com/soicon/data.rar
    Trong đó gồm 1 table hệ thống TK font unicode, 1 table HTTK font VNI và 1 table Nhật ký chung với số liệu mẫu dùng trong bài tập này.


    -----------
    Bài giải: Tuần sau sẽ có.

  8. #8
    Ngày tham gia
    Feb 2016
    Bài viết
    32
    Ðề: Treeview trong access

    Anh muontennguoi ơi làm ơn gửi cho 1 file .mdb có treeview để em tham khảo được không?

  9. #9
    Ngày tham gia
    Aug 2015
    Bài viết
    0
    Ðề: Treeview trong access

    Em tìm đc một file .MBD về treeview access 2000, các bác down về nghiên cứu thử nhé. Chúc thành công
    http://www.imageshack.us/?pickup=80131599461615
    hoặc :
    www.infotrakker.com/ProgSamples/Treeview_2000.zip

  10. #10
    Ngày tham gia
    Aug 2015
    Bài viết
    0
    Ðề: Treeview trong access

    Theo bài hướng dẫn của bác phatnq2002 và bác muontennguoi, em đã thực hiện được việc tạo treeview. Xin các bác hướng dẫn thêm về việc lọc treeview theo dữ liệu của textbox hoặc combobox được không ạ
    Em ví dụ thế này :
    ta co 1 treeview trong 1 form chứa danh sách khoa của trường, trong khoa có nhiều lớp, trong lớp có nhiều học sinh. Trên form này có 1 textbox hoặc 1 combobox danh sách khoa
    Khi ta gõ vào textbox hoặc chọn trên combobox 1 khoa nào đó, thì treeview sẽ tự động lọc và thể hiện khoa đó (cùng các lớp, các học sinh của khoa đó) lên treeview thôi.
    Xin các bác hướng dẫn thêm ạ

 

 
Trang 1 của 2 12 CuốiCuối

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •