About Inhheritance of Window Form 
Author Message
 About Inhheritance of Window Form

I have written a Window Form with a Toolbar and  form2 is inherited from
this form.

form2 also has the toolbar as the original form, but when I add more
toolbarbutton to it, it raises errors.

If the original toolbar has no toolbarbutton, it runs.

Does anyone know how to add toolbarbutton to the inherited toolbar with
buttons?

Or what's the purpose of inherited form if it cannot do change to it?



Sun, 30 Jan 2005 18:01:28 GMT  
 About Inhheritance of Window Form
It's probably a protection or scope issue. What are the errors?

-Andy

Andy Johns
Senior Consultant-Architect
Magenic Technologies


Quote:
> I have written a Window Form with a Toolbar and  form2 is inherited from
> this form.

> form2 also has the toolbar as the original form, but when I add more
> toolbarbutton to it, it raises errors.

> If the original toolbar has no toolbarbutton, it runs.

> Does anyone know how to add toolbarbutton to the inherited toolbar with
> buttons?

> Or what's the purpose of inherited form if it cannot do change to it?



Mon, 31 Jan 2005 03:05:31 GMT  
 About Inhheritance of Window Form
Hi George,
We are having trouble reproducing your problem.  Can you isolate this to a
small repro and repost your code?
Thanks,
Steve and Sunder
VB.Net

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> I have written a Window Form with a Toolbar and  form2 is inherited from
> this form.

> form2 also has the toolbar as the original form, but when I add more
> toolbarbutton to it, it raises errors.

> If the original toolbar has no toolbarbutton, it runs.

> Does anyone know how to add toolbarbutton to the inherited toolbar with
> buttons?

> Or what's the purpose of inherited form if it cannot do change to it?



Mon, 31 Jan 2005 04:55:46 GMT  
 About Inhheritance of Window Form
When I put toolbarbuttons to the toolbar inherited from another form,  it
raised error saying that  (Property 'Rectangle' is 'Readonly' ).

When I looked at the code, the error raised when setting the rectangle
property of the toolbarbuttons defined in the original form.

I found that the rectangle property of toolbarbutton cannot be set in the
original and inherited form.

I think as I put more buttons in the toolbar , so the location became
invalid.
I comment those lines and the program runs fine.

But if I have a lot of form inherited from the base form, I have to do much
to comment out these code.

Is there any way to make the toolbarbutton rectangle property change
dynamically when I add more buttons to the inherited toolbar

And avoid it generates the code point to the rectangle area not longer
valid.

I have tried to change the modifier of the toolbar and toolbarbuttons in the
original form, but it seems no effect to this problem.

Thanks for any suggestion or advice.


Quote:
> It's probably a protection or scope issue. What are the errors?

> -Andy

> Andy Johns
> Senior Consultant-Architect
> Magenic Technologies



> > I have written a Window Form with a Toolbar and  form2 is inherited from
> > this form.

> > form2 also has the toolbar as the original form, but when I add more
> > toolbarbutton to it, it raises errors.

> > If the original toolbar has no toolbarbutton, it runs.

> > Does anyone know how to add toolbarbutton to the inherited toolbar with
> > buttons?

> > Or what's the purpose of inherited form if it cannot do change to it?



Mon, 31 Jan 2005 11:20:28 GMT  
 About Inhheritance of Window Form
Hi George ,
This does appear to be a bug.  Thanks for bringing it to our attention.  It
appears that the designer is spitting incorrect code when attempting to
reorder inherited buttons on the toolbar.  We do have a workaround:

instead of reordering your buttons in the buttons collection editor, you can
do it dynamically in the New sub.  After the initializecomponent call add
the code to clear the toolbar and reorder your buttons.  Here's an example:

Assuming you have a toolbar in Form1 with toobarbutton1 and toolbarbutton2
Inherit Form1 in Form2 and add 3 more toolbarbuttons
Here's the code for the Sub New in Form2

Public Sub New()
     MyBase.New()

     'This call is required by the Windows Form Designer.
     InitializeComponent()

     'Add any initialization after the InitializeComponent() call
     Me.ToolBar1.Buttons.Clear()
     Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton()
{Me.ToolBarButton3, Me.ToolBarButton1, Me.ToolBarButton2, Me.ToolBarButton5,
Me.ToolBarButton4})
End Sub

Hope this helps.
Steve, Ernest and Sunder
VB.Net
--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> The attached is a small repro.

> There are two forms in it, form2 is inherited from form1.

> form1 has a toolbar and two toolbarbuttons.

> in form2, i add two more toolbarbuttons to the toolbar and arrange them
> upper to two inherited buttons.

> when running form2, the code setting rectangle property of form1
> toolbarbuttons will raise error as the location of them has changed.

> Any method to avoid defining the rectangle property or let it get the
> rectangle dynamically?



> > Hi George,
> > We are having trouble reproducing your problem.  Can you isolate this to
a
> > small repro and repost your code?
> > Thanks,
> > Steve and Sunder
> > VB.Net

> > --
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.



> > > I have written a Window Form with a Toolbar and  form2 is inherited
from
> > > this form.

> > > form2 also has the toolbar as the original form, but when I add more
> > > toolbarbutton to it, it raises errors.

> > > If the original toolbar has no toolbarbutton, it runs.

> > > Does anyone know how to add toolbarbutton to the inherited toolbar
with
> > > buttons?

> > > Or what's the purpose of inherited form if it cannot do change to it?



Tue, 01 Feb 2005 03:48:38 GMT  
 About Inhheritance of Window Form
Thanks you for your advice.



Quote:
> Hi George ,
> This does appear to be a bug.  Thanks for bringing it to our attention.
It
> appears that the designer is spitting incorrect code when attempting to
> reorder inherited buttons on the toolbar.  We do have a workaround:

> instead of reordering your buttons in the buttons collection editor, you
can
> do it dynamically in the New sub.  After the initializecomponent call add
> the code to clear the toolbar and reorder your buttons.  Here's an
example:

> Assuming you have a toolbar in Form1 with toobarbutton1 and toolbarbutton2
> Inherit Form1 in Form2 and add 3 more toolbarbuttons
> Here's the code for the Sub New in Form2

> Public Sub New()
>      MyBase.New()

>      'This call is required by the Windows Form Designer.
>      InitializeComponent()

>      'Add any initialization after the InitializeComponent() call
>      Me.ToolBar1.Buttons.Clear()
>      Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton()
> {Me.ToolBarButton3, Me.ToolBarButton1, Me.ToolBarButton2,
Me.ToolBarButton5,
> Me.ToolBarButton4})
> End Sub

> Hope this helps.
> Steve, Ernest and Sunder
> VB.Net
> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.



> > The attached is a small repro.

> > There are two forms in it, form2 is inherited from form1.

> > form1 has a toolbar and two toolbarbuttons.

> > in form2, i add two more toolbarbuttons to the toolbar and arrange them
> > upper to two inherited buttons.

> > when running form2, the code setting rectangle property of form1
> > toolbarbuttons will raise error as the location of them has changed.

> > Any method to avoid defining the rectangle property or let it get the
> > rectangle dynamically?



> > > Hi George,
> > > We are having trouble reproducing your problem.  Can you isolate this
to
> a
> > > small repro and repost your code?
> > > Thanks,
> > > Steve and Sunder
> > > VB.Net

> > > --
> > > This posting is provided "AS IS" with no warranties, and confers no
> > rights.



> > > > I have written a Window Form with a Toolbar and  form2 is inherited
> from
> > > > this form.

> > > > form2 also has the toolbar as the original form, but when I add more
> > > > toolbarbutton to it, it raises errors.

> > > > If the original toolbar has no toolbarbutton, it runs.

> > > > Does anyone know how to add toolbarbutton to the inherited toolbar
> with
> > > > buttons?

> > > > Or what's the purpose of inherited form if it cannot do change to
it?



Tue, 01 Feb 2005 16:25:26 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Displaying a window form in another window form

2. Launch Windows form, from a Windows Service Application

3. ?Listing open child windows on a Window submenu on MDI form

4. Debugging Code Window and Form Window Simultaneously

5. Windows Keys to Mix/Max Form (window)

6. VB 6.0 windows form not displaying properly in windows server 2008

7. Windows NT Users form a Windows 95 / 98 Client

8. Form window title while form is running

9. Windows Forms to ASPX Web forms?

10. exception on form.show (vb.Net windows forms)

11. Passing values from Windows Form to Web Form

12. Unhandled exception in system.windows.forms.dll (in my main form) - argh

 

 
Powered by phpBB® Forum Software