CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: list control

  1. #1
    Join Date
    Apr 2006
    Location
    BANGALORE,INDIA
    Posts
    75

    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

  2. #2
    Join Date
    Jul 2005
    Location
    E: 120°.6, N: 31°.3′
    Posts
    795

    Re: list control

    Simply use InsertColumn() function and set your columnhead string that's you want . then will get what u want .

  3. #3
    Join Date
    Apr 2006
    Location
    BANGALORE,INDIA
    Posts
    75

    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?

  4. #4
    Join Date
    Apr 2006
    Location
    Buenos Aires - Argentina
    Posts
    31

    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

  5. #5
    Join Date
    Dec 2002
    Location
    St.Louis MO, USA
    Posts
    672

    Re: list control

    A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.

    NAUMAAN

  6. #6
    Join Date
    Apr 2006
    Location
    Buenos Aires - Argentina
    Posts
    31

    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

  7. #7
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    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

  8. #8
    Join Date
    Apr 2006
    Location
    BANGALORE,INDIA
    Posts
    75

    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

  9. #9
    Join Date
    Sep 2005
    Location
    Singapore
    Posts
    8

    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");

  10. #10
    Join Date
    Apr 2006
    Location
    Buenos Aires - Argentina
    Posts
    31

    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
  •  





Click Here to Expand Forum to Full Width

Featured