views:

161

answers:

2

I have a form that has textboxes that display various code values. If I click within one of the textboxes that displays a code, how do i show the description value from the listview subitem into an adjacent textbox? The user clicks on a button to select a list of codes from a Listview that displays both the code and description values from the database.

I need to be able to display the appropriate description per code (there are 200 codes)

To be more specific:

If I click on textbox1(code1 value), the appropriate description1 should appear in the "Description Textbox".

If I clik on textbox2 (code2 value), the appropriate description2 should appear in the "Description Textbox".

Current Approach below that only works once.. and does not work when you for example: click on textbox1, then textbox2, but change your mind and want to see the description for textbox20. Textbox1's description is still displayed.

Code implemented thus far:

private void txtbYTRDICD1_MouseDown(object sender, MouseEventArgs e)
{
    txtbICDDiagDesc.Text = _theICD9DCode.Description;
}

I'm working with C#.NET, in Visual Studio 2005. thanks tons

+2  A: 

Wow, there are a lot of Red Flags here. Why on Earth would you name something "bYRTDICD1"? Why would you put a description in a TextBox? Do you want the user to edit the description? Why would you use the MouseDown event? Can't the user use the keyboard?

Random advice:

  1. Use the Enter event, not MouseDown
  2. Put a description in a label, not a text box
  3. Use the TextBox.Tag property to store the description
  4. Use a ComboBox to let the user select stuff instead of a list view
  5. Design your UI so that descriptions are unnecessary
Hans Passant
Why on Earth would you name something "bYRTDICD1"? :))) 100%; -Use the Enter event - on even MouseHover! and in general I can recommend tooltips for the description from tag.
serhio
Thanks for the feedback, also 1.The textbox name is a user requirement.It's the name of the database field. I initially attempted to the use a LABEL instead,(ideal) because the users don't need to edit the description. However, i had trouble with the coding, which i why we are communicating :)Your alternative suggestions are valuable, however, the form was designed based upon the old apps design. So the listview stays LOL. Thanks again
Tee
"which IS why we are communicating" ..typo earlier
Tee
about the Enter Event- i tried using it first because it seemed more applicable, but again.. referring to my previous explanation..the syntax i used just didn't work to store the description in the textbox.Have a goood one and thanks.
Tee
A: 

You can use just a ToolTip control in order to dispatch descriptions on your textboxes.

myToolTip.SetToolTip(txtbYTRDICD1, _theICD9DCode.Description);
serhio
thanks, i will try this
Tee