Yes exactly. So this design will not work for this requirement. is it? any how thank you for the interest and help provided.
Shibu Krishnan
Posts
-
I want to create a treeview with my structure/class variable as nodes and update the same with custom values -
I want to create a treeview with my structure/class variable as nodes and update the same with custom valuesAs my actual structure is pretty huge as I mentioned earlier, designing a form with label & textbox for each one is difficult. So I planned to use treeview to list the items and one text box to enter value. my form is simple with 1 treeview, label and textbox. in this case,my requirement is when i select the treeitem, associated value has to be displayed in a label and change the value through text box. Hope you are clear with my struct.
-
I want to create a treeview with my structure/class variable as nodes and update the same with custom valuesSorry to post you incomplete question. I mean the address of the variable I am passing in the lParam. But again in my GetDataItem() method, i have to typecast to the corresponding variable. is it? for eg.
typedef struct address
{
CString houseName;
CString placeName;
int cnrtyCode;
char pinCode[6];
};typedef struct node
{
CString Name;
int Age;
float Height;
address adrs;
};this is my structure. and
HTREEITEM hItems, hRoot;
TVINSERTSTRUCT tvInsert;pNode->Name = "Shibu"; pNode->adrs.cnrtyCode = 91; pNode->adrs.houseName = "House No 23"; pNode->adrs.placeName = "Bnglr"; pNode->Height = 5.5; pNode->Age = 28; hRoot = m\_tree.InsertItem(\_T("Personal Data"), 0, 1); tvInsert.hParent = hRoot; tvInsert.hInsertAfter = NULL; tvInsert.item.mask = TVIF\_TEXT | TVIF\_PARAM; tvInsert.item.pszText = "Name"; hItems = m\_tree.InsertItem(&tvInsert); m\_tree.SetItemData(hItems, DWORD(&pNode->Name));
.......
.....
tvInsert.item.pszText = "Age";
hItems = m_tree.InsertItem(&tvInsert);
m_tree.SetItemData(hItems, DWORD(&pNode->Age));Now my requirement is when i select the treeitem, associated value has to be displayed in a label. Also i have to change the value (through text box entry ; one text box only) of the selected item. Each value ( name,age etc.) are of different data types. first i tried by passing address of pNode. then how to check my selection (whether user selected name/age/..). Please help me with a code portion.
-
I want to create a treeview with my structure/class variable as nodes and update the same with custom valuesYes, I used the SetItemData() and GetItemData() methods with lparam. I am passing the (DWORD). But the variables are of different data types. the value has to be changed for the selected variable. I have lots of fields in the struct and 8 structures are there in the tree. Compare and set values for each fields will be cumbersome. Can you give proper guidance. thank you
-
I want to create a treeview with my structure/class variable as nodes and update the same with custom valuesThank you for the answer. I checked the methods to insertitem to treeview. (
Quote:
HTREEITEM InsertItem( LPTVINSERTSTRUCT lpInsertStruct ); HTREEITEM InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, HTREEITEM hParent, HTREEITEM hInsertAfter ) etc..
So how can I save address of a variable in the node? Can u please share the code segment for the same or any link to the same.
-
I want to create a treeview with my structure/class variable as nodes and update the same with custom valuesI have some structures in my application (which is pretty big). To test certain error conditions, I have to input wrong values to these variables and send across another system (using udp sockets). How can I use the treeview to populate all the structures and upon user selection of one of the node (the struct variable), i wants to input error values and update the same structure variable in my app. Here is the sample
Quote:
hRoot = m_TreeView.InsertItem(_T("Messages"), 0, 1); hMainMsg = m_TreeView.InsertItem("XXXXX", 0, 1, hRoot); hSubMsg = m_TreeView.InsertItem("MsgHdr", 2, 3, hMainMsg); m_TreeView.InsertItem(_T("msgId"), 4, 5, hSubMsg); m_TreeView.InsertItem(_T("InfId"), 4, 5, hSubMsg); m_TreeView.InsertItem(_T("Seq No"), 4, 5, hSubMsg); m_TreeView.InsertItem(_T("msgLen"), 4, 5, hSubMsg); m_TreeView.InsertItem(_T("timeStamp"), 4, 5, hSubMsg);
in double click event,
HTREEITEM nodSelected = m_TreeView.GetSelectedItem();
CString strSelected = m_TreeView.GetItemText(nodSelected);HTREEITEM hParent = nodSelected; while (hParent = m\_TreeView.GetParentItem(hParent)) { CString strParent = m\_TreeView.GetItemText(hParent); if (strcmp(strParent,"Messages")==0) break; m\_TreeView.SetItemState(hParent, TVIS\_BOLD, TVIS\_BOLD); strSelected = strParent + "." + strSelected; } m\_txtMsg = strSelected + "=";
for ex. m_txtMsg will be now "XXXXX.msgHdr.msgId=" Is there any way to use this text data to assign as my variable Please help.