this is my problem:
I am using a datagrid to show certain rows of a datatable using a
dataview. I want a context menu for the datagrid to show "delete record"
as an option and for this to call a method that deletes the record from
the dataset.
I create a context menu for the datagrid and activate it on a left
button mouseDown event. I use the binding manager base to retrieve the
message ID number for the datatable.
I have created an onpopupdelete eventhandler for the delete menu item
but can not find a way to pass the message ID into the event handler. I
feel I am making this overcomplicated. here is a simplified version of
my code:
private void messagesDataGrid_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
/* here I find out what row has been clicked on in the datagrid and find
corresponding row in dataset and unique identifier (messageID)
next I find out if right button has been clicked, if it has I call this
method
*/
ShowMessagesContextMenu()
}
protected void ShowMessagesContextMenu()
{
//clear the menu
messagesContextMenu.MenuItems.Clear();
//add menu item
messagesContextMenu.MenuItems.Add("Delete",new
EventHandler(this.OnPopupDelete));
//attach to datagrid
messagesDataGrid.ContextMenu =3D messagesContextMenu;
}
Finally I have an OnPopupDelete method
protected void OnPopupDelete(object sender, System.EventArgs e)
{
//here I will delete the row from the dataset but
How do I get messageID info in here?
}
I am sure this is easier to implement than I am doing here. I seem to be
going around in circles and using too many events. Can someone please
help
thank you in advance
Labhras
*************************************************************************
*************************
The contents of this email and any attachments are confidential.
It is intended for the named recipient(s) only.
If you have received this email in error please notify the system manager
or the
sender immediately and do not disclose the contents to any one or make co
pies.
** This email was scanned for viruses, vandals and malicious content **
*************************************************************************
*************************