Help with Programming in Visual Basic.NET?
refuse2lose_2006 asked:
I have one context menu and in one of the sub menus i have created a Background Color button. The Background Color button will display the color dialog box and will change the backcolor of the selected text box only. I got it all set up but when i debug it, all the text boxes change to the same color. How do I make it where only the selected text box changes color??
Also im am useing the Microsoft Visual Studios program.
Related posts:
- Visual Basic Programming Help? michbox asked: okay i created a simple income calculator but...
- Visual Basic Programming skilled only? crazy busy 08 asked: I am trying to create a...
- Adding in hotkeys in a Visual Basic program? mad_genius575 asked: What line of code or whatever do I...
- Visual Basic Programming Help? Bipul M asked: Does anyone know the code to save...
- Microsoft Programming Languages? Visual Basic, Visual Studio.NET, etc. Please help? JackD asked: I use to program in Visual Basic 6,...
Filed Under Programming & Design |
Tagged With Context Menu, Text Boxes, Visual Studios
Comments
One Response to “Help with Programming in Visual Basic.NET?”
I think your not refering to the right obj.backcolor property.
Your button code should go something like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each obj As Object In Me.ContextMenuStrip1.Items
Me.ColorDialog1.ShowDialog()
obj.BackColor = Me.ColorDialog1.Color
Next
‘You could also directly refer to the text box using the following:
‘ContextMenuStrip1.Items(index).backcolor
End Sub
I have a project dominstrating the code in action