Identifying a control by its handler

M

Magnus.Moraberg

Hi,

I have a number of binding navigator controls on my form. I add "plus"
buttons (buttons used to add a new row to the relevant datagirdview)
to them as follows -

bindingNavigator.AddNewItem.Enabled = false;

this.bindingNavigator.Items.AddRange(new
System.Windows.Forms.ToolStripItem[]
{
...
this.bindingNavigatorAddNewItem,
...
});

Each Binding Navigator has a "plus" toolStripButton which I add an
event to as follows -

this.bindingNavigatorAddNewItem.Click += new
System.EventHandler(this.AddRowToDataGridView);

All the plus buttons have the exact same handler -
this.AddRowToDataGridView.

I was wondering if it would be possible to loop through my
BindingNavigators and identify those toolStripButtons that have
this.AddRowToDataGridView as a handler. By doing so, I can identify
all "plus" buttons and set these buttons as disabled or enabled as I
so desire.

Thanks,

Barry
 
M

Magnus.Moraberg

Hi,

I have a number of binding navigator controls on my form. I add "plus"
buttons (buttons used to add a new row to the relevant datagirdview)
to them as follows -

bindingNavigator.AddNewItem.Enabled = false;

this.bindingNavigator.Items.AddRange(new
System.Windows.Forms.ToolStripItem[]
{
            ...
            this.bindingNavigatorAddNewItem,
            ...

});

Each Binding Navigator has a "plus" toolStripButton which I add an
event to as follows -

this.bindingNavigatorAddNewItem.Click += new
System.EventHandler(this.AddRowToDataGridView);

All the plus buttons have the exact same handler -
this.AddRowToDataGridView.

I was wondering if it would be possible to loop through my
BindingNavigators and identify those toolStripButtons that have
this.AddRowToDataGridView as a handler. By doing so, I can identify
all "plus" buttons and set these buttons as disabled or enabled as I
so desire.

Thanks,

Barry

I could derive my own AddRowToDataGridViewButton class from
toolStripButton and use GetType() to identify it... What do you think?
 
M

Magnus.Moraberg

I have a number of binding navigator controls on my form. I add "plus"
buttons (buttons used to add a new row to the relevant datagirdview)
to them as follows -
bindingNavigator.AddNewItem.Enabled = false;
this.bindingNavigator.Items.AddRange(new
System.Windows.Forms.ToolStripItem[]
{
            ...
            this.bindingNavigatorAddNewItem,
            ...

Each Binding Navigator has a "plus" toolStripButton which I add an
event to as follows -
this.bindingNavigatorAddNewItem.Click += new
System.EventHandler(this.AddRowToDataGridView);
All the plus buttons have the exact same handler -
this.AddRowToDataGridView.
I was wondering if it would be possible to loop through my
BindingNavigators and identify those toolStripButtons that have
this.AddRowToDataGridView as a handler. By doing so, I can identify
all "plus" buttons and set these buttons as disabled or enabled as I
so desire.

Barry

I could derive my own AddRowToDataGridViewButton class from
toolStripButton and use GetType() to identify it... What do you think?

No, I can't do that since I would need to create a user control to
which I can't add a ToolStipButton. I'm using VC2005 and its form
designer. Any suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top