Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a telerik radgridview at my winform. It's name is gridSigortaFirmalari.
And I delegate an events on commandcellclick. It uses gridSigortaFirmalari_CommandCellClick method. I want to fire this method from antoher button. I tried this code but I don't know is it true way and
I can't define 3th parameter whic is IInputEditor.

C#
foreach (GridViewRowInfo satir in gridSigortaFirmalari.Rows)
      {
       if (Convert.ToUInt32(satir.Cells["SirketID"].Value) == 8)
            {                               
         GridViewCellEventArgs eventt = new GridViewCellEventArgs(satir, gridSigortaFirmalari.Columns["SirketID"],???);
         gridSigortaFirmalari_CommandCellClick(satir, eventt);
        }
                                
   }
Posted
Comments
Afzaal Ahmad Zeeshan 29-Jul-15 10:23am    
Where is the first function?
amagitech 29-Jul-15 10:28am    
this.gridSigortaFirm this.gridSigortaFirmalari.CommandCellClick += new Telerik.WinControls.UI.CommandCellClickEventHandler(this.gridSigortaFirmalari_CommandCellClick);

private void gridSigortaFirmalari_CommandCellClick(object sender, EventArgs e)
{
...
}
private void btnSubmit_Click(object sender, EventArgs e)
{
foreach (GridViewRowInfo satir in gridSigortaFirmalari.Rows)
{
if (Convert.ToUInt32(satir.Cells["SirketID"].Value) == 8)
{
GridViewCellEventArgs eventt = new GridViewCellEventArgs(satir, gridSigortaFirmalari.Columns["SirketID"],???);
gridSigortaFirmalari_CommandCellClick(satir, eventt);
}

}
}




Sergey Alexandrovich Kryukov 29-Jul-15 10:48am    
First of all, this is a commercial proprietary product, so Telerik customer support should help you.
—SA
amagitech 29-Jul-15 10:50am    
ok. But I wonder is it possible at windows gridview. May you suggest any source about this
Sergey Alexandrovich Kryukov 29-Jul-15 11:04am    
Did you see my answer? It does not depend on the UI classes you use. The idea is very simple.
—SA

1 solution

Please see my comment to the question.

You are messing up two different things: event invocation and just a method call. You have a method used to handle the event, so you can always call it. This is already a solution to your "problem".

But now, it sounds a bad UI design idea. Also, you should understand that you can only invoke an event from the class declaring corresponding event member, nowhere else, not even from a derived class. So, you cannot invoke the event directly in the methods of any other types. This is an important fool-proof feature of .NET. (Of course, the declaring type can expose some methods invoking the event indirectly.)

You can handle events more conveniently, which includes the possibility to get the same effect as the event handling by calling a method, if you use anonymous methods. For example, you are not really using the event arguments parameters, so the handling can be easier:
C#
this.gridSigortaFirmalari.CommandCellClick += (sender, eventArgs) =>
{
   HandleCommandCellClick(); // you can call this method elsewhere
}


—SA
 
Share this answer
 
Comments
amagitech 29-Jul-15 11:18am    
Ok I understand
Sergey Alexandrovich Kryukov 29-Jul-15 11:46am    
Great.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900