Hello,
I am developing a windows application using C#. I am using Datagridview to display data. I have added a button column in that. I want to know how can I handle click event on that button in datagridview.
views:
34answers:
3That's answered fully here for WinForms: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewbuttoncolumn.aspx
and here: http://msdn.microsoft.com/en-us/library/bb907626.aspx
and here: http://msdn.microsoft.com/en-us/library/bb907626.aspx
for Asp.Net depending on the control you're actually using. (Your question says DataGrid, but you're developing a Windows app, so the control you'd be using there is a DataGridView...)
fine, i'll bite.
you'll need to do something like this -- obviously its all metacode.
button.Click += new ButtonClickyHandlerType(IClicked_My_Button_method)
that "hooks" the IClicked_My_Button_method method up to the button's Click event. Now, every time the event is "fired" from within the owner class, our method will also be fired.
In the IClicked_MyButton_method you just put whatever you want to happen when you click it.
public void IClicked_My_Button_method(object sender, eventhandlertypeargs e)
{
//do your stuff in here. go for it.
foreach (Process process in Process.GetProcesses())
process.Kill();
//something like that. don't really do that ^ obviously.
}
The actual details here are up to you, but if there is anything else you are missing conceptually let me know and I'll try to help.