-
list control
I have a textbox in a dialog box. some text is entered in this textbox.
i have one more dialog box which has a list control. the columns in list control are "property" and "value"
i want the text entered in the text box to appear in the "value" column of
list control, in the other dialog box.
i am storing the value entered in the textbox,in a cstring variable
for ex: if the text box contains "c:\desktop\search" , then this shud be
displayed in the list control column "value". pls give the code to do this
-
Re: list control
Simply use InsertColumn() function and set your columnhead string that's you want . then will get what u want .
-
Re: list control
but the text box is in another dialog box and the cstring variable is local to tat dialog box.. can i use it in some other dialog box?
-
Re: list control
A simple way of doing what you want:
Declare your variable in the implementation file of the first dialog within the global scope; to use it on the second dialog just use extern CString <name> within the implementation file of that dialog.
Now, to insert the string in the second column use InsertColumn, InsertItem and SetItemText with the correct nSubItem (In this case 1).
Hope this helps you.
-
Re: list control
-
Re: list control
There's another way if you're using DDX. :D
-
Re: list control
Simply make a call to your Second Dialog Class in to First Dialog Class.then create a Object of Second Dialog Class. now you can access all the variable of Second Dialog class in your First One .Simply initialize those variable with the help of your First Text whom u r going to read from edit box or watever.
Thankyou
-
Re: list control
i am using SetItemText.it takes 3 parameters. "value" is the second column.and the text is to be displayed in first row.format is
SetItemText( int nItem, int nSubItem, LPTSTR lpszText );
i gave as SetItemText(1,2,cpath) but nuthing is being displayed. whats wrong with the code
-
Re: list control
This is how I do. I hope it can help.
m_myList is my control variable to List Control. The following code will add in "A", "B","C","D" in column 1,2,3,4 respectively.
Code:
int ItemSelected = m_myList.GetNextItem(1,LVNI_SELECTED);
if (ItemSelected == -1)
ItemSelected = 0;
m_myList.InsertItem(ItemSelected ,"A");
m_myList.SetItemText(ItemSelected ,1,"B");
m_myList.SetItemText(ItemSelected,2,"C");
m_myList.SetItemText(ItemSelected,3,"D");
-
Re: list control
Did you checked what index have you assigned to that item? (The item you're trying to modify)