I have a winform datagridview to show customer details and it has a context menu. And I have set the datagridview selection Mode to "FullRowSelect". What i want is i want to copy the content of the clicked cell content to the clipboard. Not the whole row content. Just the cell content.
I have used the following code to show the Context Menu when it right click on the datagridview and select the row.
private void dgvCusList_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.RowIndex != -1 && e.ColumnIndex != -1)
{
if (e.Button == MouseButtons.Right)
{
DataGridViewCell clickedCell = (sender as DataGridView).Rows[e.RowIndex].Cells[e.ColumnIndex];
this.dgvCusList.CurrentCell = clickedCell;
var relativeMousePosition = dgvCusList.PointToClient(Cursor.Position);
this.cnxtMnuCusResult.Show(dgvCusList, relativeMousePosition);
}
}
}
I want to copy the the cell content to clipboard when i click copy menu item in my context menu. Please help me to solove this matter. Thanks in advance. :)
Clipboard.SetText
and not the code to open your context menu strip. – etaiso