Hi Team,
I am working on developing a reporting tool, user would like to show all the column headers in one list box and they would like to drag and drop the required fields in a treeview box. From Tree view box they will be filtering further more for the report.
This is similar to PIVOT TABLE functionality we use in excel. list of fieldnames, drag and drop option for ROWS and COLUMNS treeview box. An additional requirement is we will have the filter option with the checkboxes in Treeview, when the treeview loads the child value from query based on the fieldnames.
I have designed the LISTVIEW and took some code that helps me to construct the code to bring all the required table headers in listbox. Now I am having challenge to drag and drop the listview item to treeview and the treeview should load the child from a query (QryConsolidatedData) data.
Please could someone help me to drag and drop the listview item to treeview item and the tree view will immediately loads the childs for the dropped column.
So far my code goes like this - Private Sub Form_Load()
-
-
Dim strSQL As String
-
Dim nodSelected As Node
-
Dim lv As ListView
-
Set lv = Me.FColumns.Object
-
Dim adCmdText
-
adCmdText = 1
-
lv.ListItems.Clear
-
lv.ColumnHeaders.Clear
-
-
'Update the listview box to show the positions held
-
strSQL = "SELECT BuildKey([ID]) AS ItemKey" & _
-
" ,[1FieldNames] as Columns" & _
-
" FROM [test]" & _
-
" WHERE BuildKey([1Required]) = TRUE"
-
-
-
'Build the list view
-
lv.ListItems.Clear
-
With CurrentProject.Connection
-
AddLVItems lv, .Execute(strSQL, , adCmdText), , , "2400,0"
-
'"2880,2160"
-
End With
-
-
-
End Sub
-
-
-
-
Public Function BuildKey(ParamArray varKeyValues() As Variant) As String
-
'Joins the values of the passed varKeyValues to build a key.
-
'ALL Node keys MUST begin with a character. For simplicity, this code
-
'uses a constant, tv_conKeyDesignator, for this character. Also, for
-
'simplicity, all values used to build the key are separated by a constant,
-
'tv_conKeySeparator. This methodology is used in order to create a consistent
-
'approach to building the nodes/keys on a tree view object.
-
'
-
'NOTE: In order to maintain consistency, it is recommended that you
-
'set the PathSeparator property of the treeview object to be equivalent to
-
'tv_conKeySeparator
-
-
Dim strTemp As String 'A 'working' string value
-
-
'Build the key.
-
strTemp = tv_conKeyDesignator & Join(varKeyValues(), tv_conKeySeparator)
-
-
'Return the result
-
BuildKey = Trim(strTemp)
-
-
End Function
-
-
-
-
Public Sub AddLVItems(lv As ListView, _
-
rst As ADODB.Recordset, _
-
Optional intKeyOrdinal As Integer = 0, _
-
Optional intItemOrdinal As Integer = 1, _
-
Optional strColumnWidths As String)
-
'Fills a List View object with the records from the passed rst
-
-
Dim intTotCount As Integer
-
Dim fld As ADODB.Field
-
Dim colNewColumn As ColumnHeader 'A list view column header
-
Dim liNewRow As ListItem 'An Item in the list
-
Dim x As Long
-
Dim lngSubItem As Long
-
Dim strArrColumnWidths() As String
-
-
'Clear the list view
-
lv.ListItems.Clear
-
lv.ColumnHeaders.Clear
-
-
'Set Column Headers and set to report view
-
For Each fld In rst.Fields
-
If fld.Name <> rst(intKeyOrdinal).Name Then
-
Set colNewColumn = lv.ColumnHeaders.Add(, fld.Name, fld.Name)
-
End If
-
Next fld
-
lv.View = lvwReport
-
-
'Set Column widths
-
If strColumnWidths = "" Then
-
'Do Nothing
-
Else
-
strArrColumnWidths = Split(strColumnWidths, lv_conCSVSeparator)
-
For x = LBound(strArrColumnWidths) To UBound(strArrColumnWidths) - 1
-
lv.ColumnHeaders(x + 1).Width = CInt(strArrColumnWidths(x))
-
Next x
-
End If
-
-
'Loop through the rst and fill the list view
-
Do Until rst.EOF
-
-
'Add the row identifier ... which is the first field of the rst
-
Set liNewRow = lv.ListItems.Add(, rst(intKeyOrdinal).Value, CStr(rst(intItemOrdinal).Value))
-
-
'Add the sub-items (other columns) of the row
-
For Each fld In rst.Fields
-
If fld.Name <> rst.Fields(intKeyOrdinal).Name _
-
And fld.Name <> rst.Fields(intItemOrdinal).Name Then
-
lngSubItem = lngSubItem + 1
-
liNewRow.SubItems(lngSubItem) = Nz(fld.Value, "")
-
End If
-
Next fld
-
lngSubItem = 0 'Clears the sub item index
-
-
'Move to the next record
-
rst.MoveNext
-
-
Loop
-
-
End Sub
Try looking through the video series by TheSmileyCoder. He has done extensive work on his tutorials and I'm sure that it will help you.
2 3534
Try looking through the video series by TheSmileyCoder. He has done extensive work on his tutorials and I'm sure that it will help you.
Thank for the reply Seth. But unfortunately I do not have access to view the video in office, I will try to look at it once I reach home.
In the mean time please could you help me to code the treeview part.
I managed to move the selected data from List view to tree view. I am now stuck in to the Treeview part. How can I load the child nodes for all the field items I populated in the Treeview.
Please could someone help me to populate the child nodes from query for all fieldnames I have populated.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: #Hai |
last post by:
Hi,
I have a TreeView control with hierarchy:
A
| - B // source
| - C
D // dest
| - E
Whenever draging B in to D, Item B is removed and B is added into D...
|
by: PeteCresswell |
last post by:
I'm doing a metadata app.
One of the screens is a TreeView of all the codes (i.e. allowed
values) from various systems.
Other screens list systems, databases, tables, and elements (i.e....
|
by: Dave harris |
last post by:
Is anyone aware of any issues with Drag and Drop in a
treeview having trouble scrolling past the top/bottom?
For this particular control, scrolling down works about
50% of the time and is pretty...
|
by: Qingdong Z. |
last post by:
I have a VS.NET windows application which use drag-drop feather. It works
fine when application start, but stops working after application run one or
two days. The application is related to Video...
|
by: pooja |
last post by:
i need to implement drag and drop in treeview in VB.
Kindly help.
My treeview contains activities maintained using XML Files.
Hopefully, Thanks.
|
by: Alan T |
last post by:
I have a tree view on the left and a list view on the right.
I will drag and drop from list view to treeview,
and also drag drop tree node on the same tree view.
How do I differentiate I drag...
|
by: shaznay2 |
last post by:
I need some help! I'm trying to set up two drop down menus where the
first displays the Department and the second displays the names of the
printers found in the department.
So far i have two...
|
by: bob |
last post by:
Hi all,
I have a treeview that has drag drop.
Works well enough but...
If you drag out of bounds of the treeview the nodrop icon comes on.
Fair enough.
But when I move back inside the treeview...
|
by: =?Utf-8?B?QW5kcmV3?= |
last post by:
I have some code that I use to drag and drop from treeview to treeview, now I
want to adapt the code to drag and drop from listview to treeview. I am
having problems adapting the code nor can I...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |