Link to home
Start Free TrialLog in
Avatar of allanmark
allanmark

asked on

Toolstrip on BaseForm - not accessible on inherited form

Greetings all

I added a toolstrip control to a baseForm and then proceeded with the manual steps necessary to inherit a form in C# Express. Everythign works fine - except for the toolstrip container. I have tried setting the modifer to Protected and to Publci -- the properties remain Readonly in the inherited form. From what I understand, controls will have to be added programmatically?

How do I:

1.  Add, programmatically, a control to the toolstrip
2.  Code an appropriate event for teh control (eg ToolstripButton_Click)
3. Refer to teh valkues contained in the toolstrip controls?


In advance, thanks!!!

   allanmark
SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of allanmark
allanmark

ASKER

Thanks!

I've scratched around and found the programmatic way (see snippet). Only problem - the control is not showing on the toolbar - If I click where it should be, it executes the button click correctly.

Ideas?
   private void InheritedForm_Load_1(object sender, EventArgs e)
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InheritedForm));
 
            ToolStripButton bts = new ToolStripButton();
            bts.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            bts.Image = ((System.Drawing.Image)(resources.GetObject(@"D:\key.png")));
            bts.ImageTransparentColor = System.Drawing.Color.Magenta;
            bts.Size = new System.Drawing.Size(23, 22);
            bts.TextAlign = ContentAlignment.MiddleRight;
            bts.Text = "Print";
            bts.Click += new System.EventHandler(this.bts_Click);
            toolStrip1.Items.Add(bts);
            
        }

Open in new window

screendump.jpg
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial