list box text to edit box 
Author Message
 list box text to edit box

can anyone tell me how to specify text for a selection in a list box? for
example, if i click on the "United States" selection in the listbox, then
some specified text about it or something will appear automatically in the
edit box. i'm also having trouble getting the text to appear on the edit box
from the list box. can anyone help me out? the best help i could find on a
website was how to get an item from an edit box to a list box. Thank you in
advance!

Randy



Tue, 06 Apr 2004 05:47:53 GMT  
 list box text to edit box
I don't have my reference here with me, but I think you can hook into the
LB_SELCHANGE (check spelling) event and simply add the text to the edit
control by doing UpdateData(false) after assigning the member variable for
the edit control.  That way when ever the selection changes in the listbox
it will also change the edit control.

Tom


Quote:
> can anyone tell me how to specify text for a selection in a list box? for
> example, if i click on the "United States" selection in the listbox, then
> some specified text about it or something will appear automatically in the
> edit box. i'm also having trouble getting the text to appear on the edit
box
> from the list box. can anyone help me out? the best help i could find on a
> website was how to get an item from an edit box to a list box. Thank you
in
> advance!

> Randy



Tue, 06 Apr 2004 15:16:08 GMT  
 list box text to edit box
Hi Randy,

Try to trap the NM_CLICK notification message and use SetDlgItemText to output the specified text to the Edit Box.

For more information about how to trap NM_CLICK message, please visit:
http://support.microsoft.com/support/kb/articles/Q147/8/42.ASP

I hope this helps. If you have additional questions on this topic, please reply to this posting.

Need quick answers to questions like these? The Microsoft Knowledge Base provides a wealth of information that you can use to troubleshoot a problem or answer a
question! It's located at http://support.microsoft.com/support/c.asp?M=F>.

This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use. Copy Right, 2001 Microsoft Corporation. All rights reserved.

Regards,
Felix Wu

--------------------

Quote:

>Newsgroups: microsoft.public.vc.mfc
>Subject: list box text to edit box
>Lines: 11
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

>Date: Thu, 18 Oct 2001 21:47:53 GMT
>NNTP-Posting-Host: 24.5.188.39

>X-Trace: news1.rdc1.ga.home.com 1003441673 24.5.188.39 (Thu, 18 Oct 2001 14:47:53 PDT)
>NNTP-Posting-Date: Thu, 18 Oct 2001 14:47:53 PDT

>Path: cppssbbsa01.microsoft.com!news-out.cwix.com!newsfeed.cwix.com!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!

news1.rdc1.ga.home.com.POSTED!not-for-mail

- Show quoted text -

Quote:
>Xref: cppssbbsa01.microsoft.com microsoft.public.vc.mfc:298408
>X-Tomcat-NG: microsoft.public.vc.mfc

>can anyone tell me how to specify text for a selection in a list box? for
>example, if i click on the "United States" selection in the listbox, then
>some specified text about it or something will appear automatically in the
>edit box. i'm also having trouble getting the text to appear on the edit box
>from the list box. can anyone help me out? the best help i could find on a
>website was how to get an item from an edit box to a list box. Thank you in
>advance!

>Randy



Tue, 06 Apr 2004 15:45:38 GMT  
 list box text to edit box
Hi,
Sorry for the trouble, i am a newbie at this stuff so please bear with me!
After i get =NM_CLICK trapped and everything declared, where specifically do
the put the SetDlgItemText and the text for it? I have tried lotsa places
and none worked. Here is what i have now:
void CFormulas_2Dlg::OnL() //OnL is for the list box
{
 // TODO: Add your control notification handler code here
 //m_E is the edit box
 m_E.SetDlgItemText(1, "test");

 m_E.SetDlgItemText(2, "test2");

Quote:
}

void CFormulas_2Dlg::OnE()
{
I have tried switching the E to L and still didn't work, and i have tried
put the m_E.SetDlgItemText(1, "test");
under one of the strings in the list box like: m_L.AddString("Example");
Nothing worked. What am i doing wrong? Thank you for helping!
Randy

Quote:
> Hi Randy,

> Try to trap the NM_CLICK notification message and use SetDlgItemText to

output the specified text to the Edit Box.
Quote:

> For more information about how to trap NM_CLICK message, please visit:
> http://support.microsoft.com/support/kb/articles/Q147/8/42.ASP

> I hope this helps. If you have additional questions on this topic, please

reply to this posting.
Quote:

> Need quick answers to questions like these? The Microsoft Knowledge Base

provides a wealth of information that you can use to troubleshoot a problem
or answer a
Quote:
> question! It's located at http://support.microsoft.com/support/c.asp?M=F>.

> This posting is provided "AS IS" with no warranties, and confers no

rights. You assume all risk for your use. Copy Right, 2001 Microsoft
Corporation. All rights reserved.
Quote:

> Regards,
> Felix Wu

> --------------------

> >Newsgroups: microsoft.public.vc.mfc
> >Subject: list box text to edit box
> >Lines: 11
> >X-Priority: 3
> >X-MSMail-Priority: Normal
> >X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

> >Date: Thu, 18 Oct 2001 21:47:53 GMT
> >NNTP-Posting-Host: 24.5.188.39

> >X-Trace: news1.rdc1.ga.home.com 1003441673 24.5.188.39 (Thu, 18 Oct 2001
14:47:53 PDT)
> >NNTP-Posting-Date: Thu, 18 Oct 2001 14:47:53 PDT


http://home.com/faster
Quote:
> >Path:

cppssbbsa01.microsoft.com!news-out.cwix.com!newsfeed.cwix.com!newsfeed.direc
t.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!

- Show quoted text -

Quote:
> news1.rdc1.ga.home.com.POSTED!not-for-mail
> >Xref: cppssbbsa01.microsoft.com microsoft.public.vc.mfc:298408
> >X-Tomcat-NG: microsoft.public.vc.mfc

> >can anyone tell me how to specify text for a selection in a list box? for
> >example, if i click on the "United States" selection in the listbox, then
> >some specified text about it or something will appear automatically in
the
> >edit box. i'm also having trouble getting the text to appear on the edit
box
> >from the list box. can anyone help me out? the best help i could find on
a
> >website was how to get an item from an edit box to a list box. Thank you
in
> >advance!

> >Randy



Tue, 06 Apr 2004 21:09:27 GMT  
 list box text to edit box
OK, there are a couple approaches. For example, forget any solution
that uses UpdateData; the mechanism is not needed.

void CFormulas_2Dlg::OnSelChangeL()
   {
    int n = m_E.GetCurSel();
    if(n < 0)
        return; // no selection
    CString s;
    m_E.GetLBText(n, s);

The string s now contains the text you want. But a more intersting
thing to do is that when you load the information into the list box,
you do so from a structure (note you said ListBox, not ListCtrl, so
there is no NM_CLICK event for a ListBox, and only a EN_SELCHANGE
event). So I would load it up by doing something like

for(i = 0; ... ; i++
    {
      int n = m_E.AddString(data[i].text);
      m_E.SetItemDataPtr(n, &data[i]);
    }

Now that this has done is put a pointer to your data table in every
listbox entry. That entry contains the text you wanted to add, and all
the related information you want to associate with it. Then, in the
OnSelChange handler, you do

        MyData * data = (MyData *)m_E.GetItemDataPtr(n);
then you can extract whatever you want from your data structure and
display it.

If you are doing this with a CListCtrl, there is also an ItemData
field associated with each entry.
                        joe

On Fri, 19 Oct 2001 13:09:27 GMT, "WorkWithMe\(TRUE\)"

Quote:

>Hi,
>Sorry for the trouble, i am a newbie at this stuff so please bear with me!
>After i get =NM_CLICK trapped and everything declared, where specifically do
>the put the SetDlgItemText and the text for it? I have tried lotsa places
>and none worked. Here is what i have now:
>void CFormulas_2Dlg::OnL() //OnL is for the list box
>{
> // TODO: Add your control notification handler code here
> //m_E is the edit box
> m_E.SetDlgItemText(1, "test");

> m_E.SetDlgItemText(2, "test2");

>}

>void CFormulas_2Dlg::OnE()
>{
>I have tried switching the E to L and still didn't work, and i have tried
>put the m_E.SetDlgItemText(1, "test");
>under one of the strings in the list box like: m_L.AddString("Example");
>Nothing worked. What am i doing wrong? Thank you for helping!
>Randy


>> Hi Randy,

>> Try to trap the NM_CLICK notification message and use SetDlgItemText to
>output the specified text to the Edit Box.

>> For more information about how to trap NM_CLICK message, please visit:
>> http://support.microsoft.com/support/kb/articles/Q147/8/42.ASP

>> I hope this helps. If you have additional questions on this topic, please
>reply to this posting.

>> Need quick answers to questions like these? The Microsoft Knowledge Base
>provides a wealth of information that you can use to troubleshoot a problem
>or answer a
>> question! It's located at http://support.microsoft.com/support/c.asp?M=F>.

>> This posting is provided "AS IS" with no warranties, and confers no
>rights. You assume all risk for your use. Copy Right, 2001 Microsoft
>Corporation. All rights reserved.

>> Regards,
>> Felix Wu

>> --------------------

>> >Newsgroups: microsoft.public.vc.mfc
>> >Subject: list box text to edit box
>> >Lines: 11
>> >X-Priority: 3
>> >X-MSMail-Priority: Normal
>> >X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
>> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

>> >Date: Thu, 18 Oct 2001 21:47:53 GMT
>> >NNTP-Posting-Host: 24.5.188.39

>> >X-Trace: news1.rdc1.ga.home.com 1003441673 24.5.188.39 (Thu, 18 Oct 2001
>14:47:53 PDT)
>> >NNTP-Posting-Date: Thu, 18 Oct 2001 14:47:53 PDT

>http://home.com/faster
>> >Path:
>cppssbbsa01.microsoft.com!news-out.cwix.com!newsfeed.cwix.com!newsfeed.direc
>t.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!
>> news1.rdc1.ga.home.com.POSTED!not-for-mail
>> >Xref: cppssbbsa01.microsoft.com microsoft.public.vc.mfc:298408
>> >X-Tomcat-NG: microsoft.public.vc.mfc

>> >can anyone tell me how to specify text for a selection in a list box? for
>> >example, if i click on the "United States" selection in the listbox, then
>> >some specified text about it or something will appear automatically in
>the
>> >edit box. i'm also having trouble getting the text to appear on the edit
>box
>> >from the list box. can anyone help me out? the best help i could find on
>a
>> >website was how to get an item from an edit box to a list box. Thank you
>in
>> >advance!

>> >Randy

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Wed, 07 Apr 2004 00:29:58 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Wrapping text in text box or edit box

2. writing to a list box or edit box from C

3. Displaying Integers in an Edit Box or List Box

4. Disabling editing of list box items in the file open dialog box

5. edit box and list box questins

6. List with columns containing both text and combo boxes / check boxes

7. Text box or List box or other?

8. press enter in an edit box and make it happen in an other edit box too

9. *** Edit box *** Edit Box *****

10. **** Edit box *** Edit box ***

11. Using a list box to edit labels in a list control

12. Transfer of data from an edit box in one dialog box to a list box in another dialog box II

 

 
Powered by phpBB® Forum Software