Skip to main content

Select the first line in a data grid

  • March 3, 2016
  • 5 replies
  • 0 views

Alberto Ferraz

Hello,

I'm still the problem of a DataGrid can not select the first line.
I have to select another any first and then can select the first.
What is the solution?
Thanks
Alberto Ferraz

5 replies

Lanter Werner
  • Participating Frequently
  • March 3, 2016

Hello,

I'm still the problem of a DataGrid can not select the first line.
I have to select another any first and then can select the first.
What is the solution?
Thanks
Alberto Ferraz

Hi

After you have set up the DataGrid (binding etc.) obey a statement like

 set myDataGrid::SelectedIndex  to  -1

In SelectionChanged event code

 If myDataGrid::SelectedIndex  < 0

    exit method

end-if.

Freundliche Grüsse

Werner Lanter


Alberto Ferraz
  • Author
  • Participating Frequently
  • March 3, 2016

Hello,

I'm still the problem of a DataGrid can not select the first line.
I have to select another any first and then can select the first.
What is the solution?
Thanks
Alberto Ferraz

Hello Werner,

I tried your solution but does not work.

What happens to me is that when I select the first line does not generate the dgridClientes_SelectionChanged event.

Only when I select another any and then the first line is it works.

Do you aave you another idea?

Best Regards

Alberto Ferraz


Lanter Werner
  • Participating Frequently
  • March 3, 2016

Hello,

I'm still the problem of a DataGrid can not select the first line.
I have to select another any first and then can select the first.
What is the solution?
Thanks
Alberto Ferraz

Is the first row selected after loading the window, background light-gray or white? It should be white indicating no row selected. It is important that you set SelectedIndex to -1 as the last statement.

Werner Lanter


Alberto Ferraz
  • Author
  • Participating Frequently
  • March 5, 2016

Hello,

I'm still the problem of a DataGrid can not select the first line.
I have to select another any first and then can select the first.
What is the solution?
Thanks
Alberto Ferraz

Hi,

Already introduced the Set statement dgrid Customers::SelectedIndex to -1 in the program (as you suggested)..

It seems that does not accept the -1 because putting SelectedIndex to -1 or SelectedIndex to 0 causes the same effect (The first line appears selected).

If you SelectedIndex to 1 appears selected the second row and so now I can just select the first line.

I look forward more suggestions.

Thanks

Alberto Ferraz


Lanter Werner
  • Participating Frequently
  • March 15, 2016

Hello,

I'm still the problem of a DataGrid can not select the first line.
I have to select another any first and then can select the first.
What is the solution?
Thanks
Alberto Ferraz
I did upload a simple solution with a datagrid. I can select the first line. Werner Lanter