Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hallo People,

I have two classes:

 

Class1:

builds a form1,

form1 contains TabControl1

TabControl1 contains TabPage1

 

Class2:

user defined button inherited from button class

the buttons are drawn on the TabPage1 by clicking on it

 

Problem:

How do I get the coordinates of the TabPage1 into Class2?

Need to resize the button with mouse.

Posted

Hallo VolteFace

 

In the button I implemented a MsgBox for the button click.

 

MsgBox(DirectCast(Me.Container, TabPage))

MsgBox(DirectCast(Me.Container, String))

 

display an empty MsgBox.

Would you give me further suggestions what else could I try?

  • *Experts*
Posted
Er... Try this:
MessageBox.Show(DirectCast(Me.Container, TabPage).Location.X.ToString())

Am I correct in assuming that the button is Class2, and that it is located on the TabPage?

Posted

If I place your last code I get the error translated from German and shortened:

 

"'System.NullReferenceException' appeared in WindowsApplication1.exe

 

Additional Information: the object reference wasn't tied up to the objecti instance.

Posted

Hallo VolteFace

 

I got an advice, which has worked:

 

Dim f As Object
           f = Me.Parent.Name
MsgBox(f)

 

Thank you very much for your suggestions in any way!!!!

Posted

Hallo VolteFace!

another problem occured:

 

I programmed for rightclick on the mouse:

 

TabPageCoor = PointToScreen(Me.Location)  'Button
TabPageCoor1 = PointToScreen(Me.Parent.Location) 'TabPage1
TabPageCoor2 = PointToScreen(Me.Parent.Parent.Location) 'TabControl
TabPageCoor3 = PointToScreen(Me.Parent.Parent.Parent.Location) 'Form

MsgBox(Me.Name & TabPageCoor.X & Me.Parent.Name & TabPageCoor1.X & Me.Parent.Parent.Name & TabPageCoor2.X & Me.Parent.Parent.Parent.Name & TabPageCoor3.X)

 

The difference between the Button Coordinate and TabPage1 is always constant, when I move the form with the mouse in run time and then rightclick the button.

 

BUT!:

It is not the case for TabControl and Form. The difference of the coordinates is all the time different when I moce the form and right click the button.

 

Would you have an idea what is goin on there?!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...