Hi,
My situation:
I called a method called "AddMenu()" in the ThisWorkbook.cs's StartUp event handler in order to create my custom menu in Excel, that's fine and work perfectly.
I also have a action pane / user control containing a DataGridView display a grid of data. User can select a couple of DGVRow in the DGVCheckBoxColumn in that DGV.
Finally, I want my users to click a menuItem in the custom menu and retrieve the "selected" DGVRow information to do further processing. However, no item will be returned / selected in the menuItem_Click event handler.
My question:
Is it possible to communicate between custom menu and user control (the same AppDomain )
My code:
private void mnuItem_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault) { frmQuery q = new frmQuery();q.ReturnDataSet();
In the frmQuery user control class, a method called ReturnDataSet:
foreach (DGVRow) { if checked ... }

CommandBarButton and User Control Relationship
Alex Chertov
I solve the first question by myself, the answer is due to I use a Panel control out of the DGV.
BTW, How I can invoke the method (private or public) declared in my user control by clicking the menuItem on the custom Excel menu oppositely
Thanks.
MJC_Eagle
Hi
You need to capture the event on the commandbar item and then have this run your methods on your user control subject to it being loaded and available
Regards
DotFrammie
Thanks for your reply. Why I asked this question because I created a Login CommandBarButton on the menu, and I want to allow user to login, and then make it "grey" after login but turn to "Logout", and then user can click and logout the VSTO app, sound pretty simple in WinForm Dev right But I 'm not sure which event should I code against in VSTO 2.0 now.
Thanks for any advice.
Butt3r5
You can access the actionspane through the "Globals.ThisWorkbook" object. If you have added the DataViewGrid directly to the actionspane the code would look something like this:
DataGridView
dgv = (DataGridView)Globals.ThisWorkbook.ActionsPane.Controls["DataGridView1"];Steve Wertz
Thanks John,
Your suggested code always return "null" even though I entered the correct control name inside the square bracket. :(
BTW, How I can invoke the method (private or public) declared in my user control by clicking the menuItem on the custom Excel menu oppositely
Thanks.