tooltip position

jtoutou

Active member
Joined
Oct 11, 2008
Messages
26
Programming Experience
Beginner
hello again...
in my form for the "required" fileds i have masked text boxes.
For validation i use the MaskInputRejected event and finally i use tooltip for pop up msg.
my problem is the position of the tooltip..see the code
(the syntax i think is ok)
VB.NET:
Private Sub MaskedTextBox1_MaskInputRejected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MaskInputRejectedEventArgs) Handles MaskedTextBox1.MaskInputRejected

ToolTip1.ToolTipTitle = "text"
            ToolTip1.Show("text2.", Me.MaskedTextBox1, Me.MaskedTextBox1.Location.X, Me.MaskedTextBox1.Location.Y, 3000)
.
.
.
.
.Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.ToolTip1.IsBalloon = True
        
    End Sub

    Private Sub MaskedTextBox1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles MaskedTextBox1.KeyDown
        
        Me.ToolTip1.Hide(Me.MaskedTextBox1)
    End Sub

and i need the tool tip to be displayed nearby the specific maksed textbox
note that
1:my windows state in the main form is maximized
2: 2 docked panel inside the main form(panel 1,panel2)
3:1 sub form inside the panel2 where the masked boxes are there

the result is that the position of the tooltip msg is so different from what i need..
VB.NET:
[CODE]
[/CODE]
VB.NET:
 
The location of a control is relative to its parent. The ToolTip.Show Method (String, IWin32Window) will display "nearby" given control (IWin32Window). If you want to give additional coordinates think of point (0,0) as top-left corner of the control, ie a point relative to the control.
 
"point (0,0) as top-left corner of the control" as you said was my mistake.I wanted to locate my tooltip exactly at the end of the masked text box.
so it works as i want like this:
VB.NET:
.
.
.        me.maskedTextBox1.show("text",Me.maskedTextBox1,Me.MaskedTextBox1.width,Me.maskedTextBox1.Height-20,3000)

this one aligns the tooltip at end of the masked text box
My mistake was the coordinates..
i have to use the size property for coordination instead of location property.
Thank you very much!!
Another question...
For a number of 10 Masked Text Boxes can i use the same tooltip or i have to create a different tooltip for each Mtb?
 
Tooltip is a component you typically add one of to form (or just a few), and use this to display tooltips for all controls. It is most often displayed for mouse hover events, which there can only be one at a time, so in this regard you only need one Tooltip instance. Since all Show overloads require IWin32Window parameter it is also apparent that this component is designed to serve multiple controls. To add to this, when you add a new Tooltip component to form all controls will get a new property named like "tooltip text on Tooltip1", so you can set default tooltip text for all controls by the one Tooltip component.
 
Back
Top