hi i have a form which contains the id number, name, address, dob and tel no. how i would like to highlight the textbox when the user clicked on a textbox or pressed the tab key. thanks
You may like to download the XP Common Controls library from the link in my signature. It includes the XPTextBox class that has a very elegant way to indicate focus. The .NET 2.0 version is currently in beta.
They are methods. You don't put method definitions inside other method defintions. To create an event handler you open the code window, select the control from the drop-down list at the top-left then select the event from the top-right. The IDE will create the appropriate empty event handler for you. You can then change the name of the method and add additional events to the Handles clause. That's exactly what I did to produce the code above. I created handlers for the TextBox1.Enter and TextBox1.Leave events, then I added the code to the body of each, changed the name to be more general and added the TextBox2 events to the Handles clauses.
I actually just tried using the XP Common Controls XPFocusProvider for the first time myself. It allows TextBoxes to be rendered normally, which the XPTextBox and XPTextBoxProvider do not, and it gives a consistent visual cue for all controls, not just TextBoxes. It is a bit more subtle and stylish than changing the BackColor too. I highly recommend it. I changed the defaults a little. The default colours are orange and dark orange, the line weight is 2 and the distance from the control is 2. I have changed that to ActiveCaption and InactiveCaption, 1 and 0 to make it more subdued.
Last edited by jmcilhinney; Feb 27th, 2006 at 10:48 PM.