Page 1 of 1

custom Open button on chartcontroller

Posted: Mon Feb 08, 2016 3:38 pm
by 15677528
I am sure this has been asked before but I could not find it.

How do I add a button to the chartcontroller next to the save button?
It has to be a open button so the user can both save and open a file.
I prefere do do it by code.

PS when I try to add a toolstripitem in design mode VS2015 shows a error: "Cannot create an abstract class"

Regards Torben

Re: custom Open button on chartcontroller

Posted: Tue Feb 09, 2016 11:54 am
by Christopher
Hi Torben,

You should be able to control the items in the chartcontroller using code similar to that indicated in the answer to this post.

Re: custom Open button on chartcontroller

Posted: Tue Feb 09, 2016 12:05 pm
by 15677528
Hi,

I dont understand how the single code line in the link helps me adding a custom button.
Can you give a simple code example that shows how to add a button next to the save button?

Regards Torben

Re: custom Open button on chartcontroller

Posted: Thu Feb 11, 2016 10:02 am
by Christopher
Hello Torben,

You could try:

Code: Select all

    private void button4_Click(object sender, EventArgs e)
    {
      ToolStripButton button = new ToolStripButton("My Button", Image.FromFile(@"D:\tmp\orion.png"), Button_Click);
      button.ImageAlign = ContentAlignment.MiddleCenter;
      button.ImageScaling = ToolStripItemImageScaling.SizeToFit;
      ((ToolStrip)chartController1).AutoSize = true;
      ((ToolStrip)chartController1).Items.Insert(((ToolStrip)chartController1).Items.Count - 1, button);
    }

    private void Button_Click(object sender, EventArgs e)
    {
      MessageBox.Show("Alnitak");
    }

Re: custom Open button on chartcontroller

Posted: Thu Feb 11, 2016 10:41 am
by 15677528
Thanks. Just what I needed

Regards Torben