About mark a row in a DataGridView

T

Tony Johansson

Hello!

I have a DataGridView of many rows mayby over 100.
To this DataGridView is a DataTable connected like this
bindingSource.DataSource = _dataTable;
dgvStock.DataSource = _bindingSource;
In this form is there also two text field where I can enter name or
productnumber
I have also a search button.
When I want to do a search I enter into the name field or the productnumber
field and then press the search button.

I loop through the DataTable after the given name or productnumber until
found or until end of DataTable.

Now to my question is there a way to mark the row in the DataGridView where
the name or productnumber was found.

//Tony
 
I

Ignacio Machin ( .NET/ C# MVP )

Hello!

I have a DataGridView of many rows mayby over 100.
To this DataGridView is a DataTable connected like this
bindingSource.DataSource = _dataTable;
dgvStock.DataSource = _bindingSource;
In this form is there also two text field where I can enter name or
productnumber
I have also a search  button.
When I want to do a search I enter into the name field or the productnumber
field and then press the search button.

I loop through the DataTable after the given name or productnumber until
found or until end of DataTable.

Now to my question is there a way to mark the row in the DataGridView where
the name or productnumber was found.

//Tony

Hi,

Just change the CSS of that row, or of that cell for that matter, you
could also add a A tag and navigate to it this will have the extra
effect of making that row visible
 
T

Tony Johansson

Hello!

I used this one it was easy it it works
dgStock.Rows.Selected = true;

//Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top