mike-wigan Posted October 6, 2005 Posted October 6, 2005 can anyone tell me how to set an tool tip from an array string ie button1 = name(0) button2 = name(1) etc Quote
bri189a Posted October 6, 2005 Posted October 6, 2005 If you only have 1 tool tip and you have a control collection which is in the same order as your array of strings in other words: Control1 Tool Tip = name(0) Control2 Tool Tip = name(1) Control3 Tool Tip = name(2) And you have all the controls in a collection you would: For i as Integer = 0 to MyCollection.Count - 1 MyToolTip.SetToolTip(MyCollection(i), name(i)) Next I wouldn't say this is good practice because your tightly couple the control length and order to names array length and order. Quote
*Experts* DiverDan Posted October 6, 2005 *Experts* Posted October 6, 2005 I think it'll be easier to interate through your form's controls, comparing names and setting the tool tip from the control name value. I am assuming that you have a 2D array with control name and tooltip fields like: myCollection(0, 0) = "txtName" myCollection(0, 1) = "Please enter your name" myCollection(1, 0) = "txtAddress" myCollection(1, 1) = "Please enter your mailing address" etc. Dim ctrl as Control Dim i as Integer For i = 0 to myCollection.GetUpperBound(0) For Each ctrl in Me.Controls If ctrl.Name = myCollection(i, 0) Then ToolTip1.SetToolTip(ctrl, (i, 1)) Exit For End If Next Next I haven't tested this but I think it should work fine. Also, if you have any controls that require tool tips in other "container" controls like Panels or GroupBoxes then you'll need to iterate through them separately. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.