SplitButton event ERROR. Not triggering the toolstripitem click event.
Hi, guys.
The SplitButton component is not triggering the Click event in the toolstripitem.
my code is like this:
var toolStripItem = new toolstripitem()
{
Text = "Add",
Image = imageList.Images["Add"]
};
toolStripItem.Click+= MethodToExecuteWhenClickOnItem;
splitButton.DropDownItems.Add(toolStripItem);
When I click on the item, the click event does not fire.
Am I missing something?
Thanks.
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
EM
Elakkiya Muthukumarasamy
Syncfusion Team
February 24, 2021 10:28 AM UTC
Hi Marlon,
Thanks for contacting Syncfusion support.
We have checked your reported query and suspect that you are trying to add toolstripitem as drop down item in the splitButton.Our recommended approach to use ToolStripMenuItem as drop down item.Please refer the UG documentation link below,
Documentation link: https://help.syncfusion.com/windowsforms/ribbon/getting-started#adding-dropdownmenuitems
Please try it with the provided solution and let us know if you need any further assistance on this.
Regards,
Elakkiya
MA
Marlon Assef
February 24, 2021 09:25 PM UTC
Hi, Elakkiya.
Thank you for the quick reply.
According to the documentation, the ToolStripMenuItem is a menu item for ToolStripDropDownButton in the RibbonControlAdv.
Unfortunately that's not the case.
We do not use the RibbonControlAdv, actually, we use a SplitButton on the form close to a text box (see image below) and the items for SplitButton are toolstripitem as described in the code previously. Also, if changed to ToolStripMenuItem the code does not compile.
Please let me know if you need more details.
Regards.
EM
Elakkiya Muthukumarasamy
Syncfusion Team
February 25, 2021 01:32 PM UTC
Hi Marlon,
Sorry for the inconvenience.
On further validating, mentioned issue “While using ToolStripItem as dropdown item of SplitButton click event not fired “ is reproduced and we have recommended to use SplitButton DropDownItemClicked event to customize the ToolStripItem. Please refer the below sample and code example for the same.
Code snippet:
|
private void SplitButton1_DropDowItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
var t = e.ClickedItem;
if(t != null && e.ClickedItem.Text == splitButton1.DropDownItems[0].Text)
{
e.ClickedItem.Image = Bitmap.FromFile(@"../../help.png");
t = e.ClickedItem;
}
} |
Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SplitButton_CustomArrow679737336
Please try it with the provided solution and let us know if you need any further assistance on this.
Regards,
Elakkiya
Marked as answer
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
- Marked answer
-
MA Marlon Assef
- Feb 23, 2021 04:04 AM UTC
- Feb 25, 2021 01:32 PM UTC