Click here to Skip to main content
15,881,802 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am VB6.0 developer and now jumped into vb.net 10
I want to highlight active control by changing its backcolor
I have done this in vb6.0 using timer but that shows jerk in screen periodically.
i want to do it in VB.Net without using timer. How i can do it.
Please help.
Posted
Updated 23-Jun-15 7:35am
v2
Comments
Ralf Meier 23-Jun-15 13:23pm    
Do we speak about a customized Control ?
hemendrapadia 23-Jun-15 13:38pm    
Simple native vb.net controls. No customized control
hemendrapadia 23-Jun-15 13:34pm    
no no customized control
Ralf Meier 23-Jun-15 13:44pm    
If you want to change the functionality or the behavior of a Control you need to customize it and add the "missing" function to your new own Control - that would be OOP.
Do you want to do it like this ?
hemendrapadia 23-Jun-15 14:14pm    
yes, i simply not want to write in each and every control's event.
I know about -enter- and -leave- event but it could be generalized.
Even i use theme window all display styles of controls decided there in that window(form)

1 solution

Howdy,
For starters you can create controls that have the behaviors you need, here is a small example:

VB
Public Class myTextBox
    Inherits TextBox

    Private Sub myTextBox_GotFocus(sender As Object, e As EventArgs) Handles Me.GotFocus
        BackColor = Color.White
        ForeColor = Color.Black
    End Sub
    Private Sub myTextBox_LostFocus(sender As Object, e As EventArgs) Handles Me.LostFocus
        BackColor = Color.FromArgb(255, 240, 240, 240)
        ForeColor = Color.FromArgb(255, 165, 165, 165)
    End Sub
End Class


Also, after you have rebuilt the solution this control will show up at the top of the Toolbox area. You can then select, drag and drop this on to your form. Although this is far from a complete example, it is easy enough to make a solution that works well with the events and actions of the Windows environment.

regs

ron O.
 
Share this answer
 
Comments
hemendrapadia 10-Jul-15 9:56am    
Thanks Bojammis

But i have to do it with all control it is not only one textbox type control
i want any type of control that can have focus.

actually i must use the word -active control backcolor change on focus-
bojammis 10-Jul-15 11:28am    
Thanks for the reply. Is creating those controls (like the example given) that have focus not a good solution? Or am I missing something.
hemendrapadia 10-Jul-15 13:13pm    
I will take this solution as last option, i m thinking other way without creating controls. i have done it in VB6.0 but forget the code, and lost my code in damaged harddisk. Anyway thank you very much for your support.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900