Textbox Event Handling
I have a form that has textboxes that display various code values开发者_JAVA技巧. 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
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:
- Use the Enter event, not MouseDown
- Put a description in a label, not a text box
- Use the TextBox.Tag property to store the description
- Use a ComboBox to let the user select stuff instead of a list view
- Design your UI so that descriptions are unnecessary
You can use just a ToolTip control in order to dispatch descriptions on your textboxes.
myToolTip.SetToolTip(txtbYTRDICD1, _theICD9DCode.Description);
精彩评论