Current location - Health Preservation Learning Network - Fitness coach - Vb.net DataGritview Usage
Vb.net DataGritview Usage
Private subdatagridview1_ mousemove (byvalsender as the object and ByVal e as the system. Windows.Forms.MouseEventArgs) handles DataGridView 1. Mouse movement

If (e.button = windows.forms.mousebuttons.left) t judges whether the left mouse button is left.

dim myGrid As DataGridView = CType(sender,DataGridView)

Dim hti As system. windows . forms . datagridview . hittest info

hti = myGrid。 HitTest(e.X,e.Y)

If you click a row header or cell.

If hti. Type = DataGridViewHitTestType。 RowHeader or hti. Type = DataGridViewHitTestType。 Then make a phone call

Dim rows as integers.

Gets the index number of the clicked row.

row = hti。 RowIndex

RoomID = myGrid(0,row)。 Value' Write down the employee number.

Roomtypename = mygrid ( 1,row)。 "value.tostring" write down the name of the employee.

DataGridView 1。 Clear selection ()

DataGridView 1。 Row. Selected = true

If ... it will be over.

ElseIf (e.Button = Windows。 Forms.MouseButtons.Right) and then

dim myGrid As DataGridView = CType(sender,DataGridView)

Dim hti As system. windows . forms . datagridview . hittest info

hti = myGrid。 HitTest(e.X,e.Y)

If you click a row header or cell.

If hti. Type = DataGridViewHitTestType。 RowHeader or hti. Type = DataGridViewHitTestType。 Then make a phone call

Dim rows as integers.

Gets the index number of the clicked row.

row = hti。 RowIndex

RoomID = myGrid(0,row)。 value

RoomTypeName = myGrid( 1,row).Value.ToString

DataGridView 1。 Clear selection ()

DataGridView 1。 Row. Selected = true

If ... it will be over.

Mark I as an integer

Because i = 0 for me. DataGridView 1。 Number of rows-1

DataGridView 1。 Line (I). ContextMenuStrip = Me。 Context menu

then

If ... it will be over.

End joint

Write according to this paragraph.