Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# datagridview select row right click

private void MyDataGridView_MouseDown(object sender, MouseEventArgs e)
{
    if(e.Button == MouseButtons.Right)
    {
        var hti = MyDataGridView.HitTest(e.X, e.Y);
        MyDataGridView.ClearSelection();
        MyDataGridView.Rows[hti.RowIndex].Selected = true;
    }
}

private void DeleteRow_Click(object sender, EventArgs e)
{
    Int32 rowToDelete = MyDataGridView.Rows.GetFirstRow(DataGridViewElementStates.Selected);
    MyDataGridView.Rows.RemoveAt(rowToDelete);
    MyDataGridView.ClearSelection();
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: get sha1 hashcode from c# 
Csharp :: xamarin picker 
Csharp :: what is reflection in programming 
Csharp :: how to set foreground from code wpf 
Csharp :: use slider in unity 
Csharp :: c# select a row from datagridview by value 
Csharp :: c# even or odd 
Csharp :: c# generate guid from hash 
Csharp :: append multi lines to file linux 
Csharp :: c# combobox add item 
Csharp :: c# switch statements 
Csharp :: get unique array based on value in c# 
Csharp :: comments in c# 
Csharp :: how to upload an image to an image source c# 
Csharp :: list min and Max value in c# 
Csharp :: c# clear an array 
Csharp :: multidimensional arrays c# 
Csharp :: c# add 2 arrays 
Csharp :: c# api bypass ssl certificate 
Csharp :: c# xml get child node by name 
Csharp :: C# round number of digits after decimal point 
Csharp :: initialize a char array java 
Csharp :: get int value from enum c# 
Csharp :: c# string methods 
Csharp :: linq string comparison case insensitive 
Csharp :: c# get set 
Csharp :: c# add list to list 
Csharp :: where to write fluent api 
Csharp :: c# create log file 
Csharp :: C# Find first thing on a list 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =