skyyakal Posted October 8, 2003 Posted October 8, 2003 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. Quote
*Experts* Volte Posted October 8, 2003 *Experts* Posted October 8, 2003 I think you can use DirectCast(Me.Container, TabPage) to return the tabpage that the button is located in. Quote
skyyakal Posted October 8, 2003 Author Posted October 8, 2003 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? Quote
*Experts* Volte Posted October 8, 2003 *Experts* Posted October 8, 2003 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? Quote
skyyakal Posted October 8, 2003 Author Posted October 8, 2003 Yes the button is Class2 and it is added to TabPage by double clicking on the TabPage. TabPage itself is programmed in Class1 Quote
skyyakal Posted October 8, 2003 Author Posted October 8, 2003 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. Quote
skyyakal Posted October 8, 2003 Author Posted October 8, 2003 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!!!! Quote
*Experts* Volte Posted October 8, 2003 *Experts* Posted October 8, 2003 Ah, of course. I seem to always get Container and Parent confused. Sorry, then. :) Glad you got it sorted anyway. Quote
skyyakal Posted October 9, 2003 Author Posted October 9, 2003 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?! Quote
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.