Smiley
Smiley

Reputation: 3437

C# - Select Rown in DataGridView

I am currently working on my datagridview which is being populated by a stored procedure's query from the database. My question is how can I select the whole row even though I only click one cell?

Example, there are four columns returned by the stored procedure. So basically the datagridview will present to me data in four columns. If I select row 2 of column 3, is it possible that the action will not only highlight the row2 column 3 but the whole row 2?

Thanks very much!

Upvotes: 0

Views: 500

Answers (3)

rerun
rerun

Reputation: 25505

There is a DataGridView.SelectionMode property you can set to fullrowselect.

Upvotes: 0

bla
bla

Reputation: 5480

You can set the SelectionMode of your datagridview to FullRowSelect:

dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

Upvotes: 1

Emil Orol
Emil Orol

Reputation: 561

DataGridView1.FirstDisplayedScrollingRowIndex = DataGridView1.Rows(counter).Index

DataGridView1.Refresh()

DataGridView1.CurrentCell = DataGridView1.Rows(counter).Cells(1)

DataGridView1.Rows(counter).Selected = True

More: http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/47e9c3ef-a8de-48c9-8e0d-4f3fdd34517e/

Upvotes: 1

Related Questions