|
-
May 8th, 2006, 03:47 AM
#1
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
-
May 8th, 2006, 04:35 AM
#2
Re: list control
Simply use InsertColumn() function and set your columnhead string that's you want . then will get what u want .
-
May 8th, 2006, 04:41 AM
#3
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?
-
May 8th, 2006, 05:48 AM
#4
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.
Last edited by CPPFanatic; May 8th, 2006 at 05:56 AM.
People who think they know everything really annoy those of us who know we don't. - Bjarne Stroustrup
-
May 8th, 2006, 06:03 AM
#5
Re: list control
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
-
May 8th, 2006, 06:10 AM
#6
Re: list control
There's another way if you're using DDX.
People who think they know everything really annoy those of us who know we don't. - Bjarne Stroustrup
-
May 8th, 2006, 06:11 AM
#7
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
-
May 8th, 2006, 06:33 AM
#8
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
-
May 8th, 2006, 06:53 AM
#9
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");
-
May 8th, 2006, 08:31 AM
#10
Re: list control
Did you checked what index have you assigned to that item? (The item you're trying to modify)
Last edited by CPPFanatic; May 8th, 2006 at 08:37 AM.
People who think they know everything really annoy those of us who know we don't. - Bjarne Stroustrup
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|