I'm setting the datasource of a DataGridView to a datatable. This
loads the grid correctly but it automatically selects the first row in
the grid, triggering the SelectionChanged event. Is there a way to
stop the grid from automatically selecting the first row?

Thanks.

RE: DataGridView automatically selects first row by Brandon

Brandon
Tue Feb 07 10:54:42 CST 2006

Try handling the DataBindingComplete() event and setting selectedIndex = -1.
--
He who dies with the most toys wins.


"Brett" wrote:

> I'm setting the datasource of a DataGridView to a datatable. This
> loads the grid correctly but it automatically selects the first row in
> the grid, triggering the SelectionChanged event. Is there a way to
> stop the grid from automatically selecting the first row?
>
> Thanks.
>
>

RE: DataGridView automatically selects first row by Nkem

Nkem
Wed Apr 19 11:56:02 CDT 2006

You would just as well do this: datagridviewname.ClearSelection(); right
after loading data.

"Brandon" wrote:

> Try handling the DataBindingComplete() event and setting selectedIndex = -1.
> --
> He who dies with the most toys wins.
>
>
> "Brett" wrote:
>
> > I'm setting the datasource of a DataGridView to a datatable. This
> > loads the grid correctly but it automatically selects the first row in
> > the grid, triggering the SelectionChanged event. Is there a way to
> > stop the grid from automatically selecting the first row?
> >
> > Thanks.
> >
> >