VB.NET Button help
Hi
I have five buttons created with VB.NET . Each button opens separate forms when user clicks on it . I like to know how to make the button user clicks on bold and rest dim . For example if the user click on button 2 that button will be bold and rest of the buttons will be dim . So only one button will be bold at at time . How to do that
Thanks
# 1 Re: VB.NET Button help
by bold button you mean font to be bold or something different? I am assuming font to be different. When the user clicks a button then in its click event write code to change the all the buttons to normal except that button, and make that button font bold.
# 2 Re: VB.NET Button help
ashishprem,
AFAIK, a button's Font properties, such as Bold, Name, etc are readonly.
Kerry Moorman
# 3 Re: VB.NET Button help
button.font.bold is readonly, but button.font is not
This means that you can assign a new font to the button, and this new font can have a bold property of true or not.
When you create a new font object, you can pass the constructor a "prototype" font which is an existing font (the button's font) and then just alter the bold property.
Here is an example to set the font bold, then normal in the button click event
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fntBold As New Font(Button1.Font, FontStyle.Bold)
Dim fntNorm As New Font(Button1.Font, FontStyle.Regular)
Button1.Font = fntBold
Button1.Font = fntNorm
End Sub
darren at 2007-11-11 21:50:21 >
