| Help with Programming in Visual Basic.NET?

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:

  1. Visual Basic Programming Help? michbox asked: okay i created a simple income calculator but...
  2. Visual Basic Programming skilled only? crazy busy 08 asked: I am trying to create a...
  3. Adding in hotkeys in a Visual Basic program? mad_genius575 asked: What line of code or whatever do I...
  4. Visual Basic Programming Help? Bipul M asked: Does anyone know the code to save...
  5. 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 , ,

Comments

One Response to “Help with Programming in Visual Basic.NET?”

  1. NoComment on June 14th, 2009 5:52 am

    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