Well, in your for each loop you are setting the string "s" to the
value of the button's text, not the RichTextBox's text. Also, this
loop is only run when the user clicks the
AddNewDriverToolStripMenuItem, meaning the tooltips won't be updated
real time.
Also you may look at the tag property. With it you can actually set
the value to an object (like say a certain RichTextBox) and then avoid
having to do a for each loop to find a particular control. Besides, a
person using a Accessibility settings will get upset with your
AccessibleNames
Instead, I would suggest you add a new usercontrol to your program. To
this user control add a RichTextBox a Button, and a ToolTip - leave
the default names for now. Next, add an event handler for the
RichTextBox's TextChanged Event :
Private Sub RichTextBox1_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RichTextBox1.TextChanged
ToolTip1.SetToolTip(Me.Button1, RichTextBox1.Text)
End Sub
This will update the ToolTip for the button whenever the text changes
in the RichTextBox. After you get everything laid out in the user
control the way you want it, instead of adding the RichTextBox and
Button to the form, just add the UserControl you just created. This
way everything is neatly self contained (encapsulated) and you don't
need to worry about it in the form it will be added to. Any features
that need to be exposed by the UserControl to the outside should be
wrapped in a property (or by bubbling events if you need to expose an
event), as it is generally a bad idea to expose an entire object.
Any further questions please ask!
Thanks,
Seth Rowe- Hide quoted text -
- Show quoted text -