Is there a way to set up the ultrawingrid (on a windows form, vb.net 2.0, windows xp) so that the active row and selected row are always the same? It is confusing to my users when a row is highlighted and then they click on another row and that becomes the active row, but it is not selected.
Thanks,
If you only need to deal with one row at a time, anyway, then you might just want to turn off selection by setting SelectTypeRow to None. Then you only have to deal with the ActiveRow.
Hi Mike,
I tried this solution but it does not work (9.2.20092.2058).
SelectTypeRow = Single;
SelectTypeCell = Single;
CellClickAction = EditAndSelectText;
In the AfterRowActivate-event I clear selected rows und add the active row to the selected rows and I have one selected row at this time and because of my configuration the clicked cell in the row is in edit mode. So far so good.
Now, if I click on any other control in my form, the grid looses focus (edit mode ends, row remains visually selected). But now, the Selected.Rows.Count is 0 !!!
What happens here? Do you how I loose the selected row?
Thanks. Markus
Hi Markus,
There's no reason I can see why the grid should lose it's selection when it loses focus.Unless your code is doing something to change the data or the current position of the BindingManager or maybe setting the grid's DataSource.
But if you are doing single-selection in the grid, anyway, why not simply always use the ActiveRow and not bother dealing with the selected row at all. You could simply turn off selection (SelectTypeRow = None) and then set the BackColor and ForeColor on the grid's ActiveRowAppearance so that the ActiveRow looks selected.
there is no code changeing something. I click on a cell and check the selected rows count at breakpoint in the AfterRowActivated-event. After that the cell is in edit mode with selected text as it should be. Then I click on a button and check the selected rows count in the button click event again. Count is 0.
Because I have application style library I don't like setting colors in certain grids. The workaround for me is to check the selected rows count and add the active row as the only one row to the selected rows collection to make sure I'm dealing with the right row.
Markus
mac_swit said:there is no code changeing something. I click on a cell and check the selected rows count at breakpoint in the AfterRowActivated-event. After that the cell is in edit mode with selected text as it should be. Then I click on a button and check the selected rows count in the button click event again. Count is 0.
That explains it, then. If there's a cell in edit mode, you cannot have a selected row. Going into edit mode on any cells clears the selection.So your selected row is getting cleared before you leave the grid - it's getting cleared almost immediately after you set it.
I am prettu confused with active row and selected row. Can you please suggest the difference b/w the two?
Thanks
Active row is the row that has the input focus and there can be only one active row which is grid.ActiveRow.
Selected row is a row that has been selected by code or by a mouse click. A single mouse click activates and selects the row that was clicked. Another click with the CTRL key selects the other row too. Selected rows can be accessed via grid.Selected.Rows.