We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Highlighting Row with keypress

In a GDBC, when I click a row, it highlights as expected. When I nav the grid using the arrow keys, I don''t get the expected highlighting. I assume I''m missing an event....which one please :)

12 Replies

AD Administrator Syncfusion Team March 1, 2005 01:27 AM UTC

Is this happening after you expand a node in a hierarchical GridDataBoundGrid? If so, I think you can avoid the problem by handling the RowExpanded event and setting a currentcell in the row.
private void gridDataBoundGrid1_RowExpanded(object sender, GridRowEventArgs e)
{
	if(!this.gridDataBoundGrid1.CurrentCell.HasCurrentCell)
		this.gridDataBoundGrid1.CurrentCell.MoveTo(e.RowIndex, 2);
}


DB Daniel Byers March 29, 2005 02:24 AM UTC

No. It''s happening in a GDBG. I click a row with the mouse, the grid gets focus, and then I arrow down through the rows. As I change rows, the background color does not change to highlight the current row.


AD Administrator Syncfusion Team March 29, 2005 09:29 AM UTC

Do you have grid.ListBoxSelection set to something other than none? This should make the row be selected when you move the currentcell either with the keyboard or the mouse. Here is a little sample that worked for me in version 3010. http://www.syncfusion.com/Support/user/uploads/GDBG_HightLight_8dbee28a.zip If you have ListBoxSelectionMode set, do you have cells disabled? If so, this would prevent a cell from becoming current whcih would in turn prevent the row from being selected.


AD Administrator Syncfusion Team March 29, 2005 03:40 PM UTC

Hi, I have used the example above and just exchanged the DataSource of the grid with my DataSet created with an SQL connection. > this.gridDataBoundGrid1.DataSource = dt; > this.gridDataBoundGrid1.DataSource = dataSet11.Table1; The current cell is not focused at startup of the form anymore. After the first click into a cell it is fine. Am I doing something wrong? I have also tried to use the GridSetCurrentCellOptions.SetFocus with the MoveTo method. > this.gridDataBoundGrid1.CurrentCell.MoveTo(1,2, GridSetCurrentCellOptions.SetFocus); Thx for help, Matt


AD Administrator Syncfusion Team March 29, 2005 03:46 PM UTC

Do you have some disabled columns? Try setting grid.ForceCurrentCellMoveTo = true before you call grid.CurrentCell.MoveTo to see if this takes care of this problem of not having an initial current cell.


AD Administrator Syncfusion Team March 29, 2005 05:05 PM UTC

Thxs, now it works... Another question related to this topic. I use a filter bar and don''t want to allow that the filter bar is the selected row in the table. As I know this is done by disabling the cells, isn''t it. How can I do this? The following code didn''t solve it. > GridStyleInfo stInfo = new GridStyleInfo(); > stInfo.Enabled = false; > theFilterBar.StyleInfo = stInfo; Br, Matt


AD Administrator Syncfusion Team March 29, 2005 05:32 PM UTC

Disabling the FilterBar row is not a good option as if you disable it, you cannot click it, and then you would not be able to use the FilterBar. One way youcould handle this is to subscribe to the grid.Model.SelectionsChanging event. In your handler, set e.Cancel = true if the e.range is the first row.
private void Model_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{
	if(e.Range.IsRows && e.Range.Top == 1)
		e.Cancel = true;
}


AD Administrator Syncfusion Team March 30, 2005 07:41 AM UTC

When clicking the filter bar the Range is always empty (IsRows is false and Top is 0). (theFilterBar.StyleInfo.Enabled is ture) Is there another way to prevent that the filter bar gets the selected row? Br, Matt


AD Administrator Syncfusion Team March 30, 2005 09:10 AM UTC

Try handling CurrentCellMoved and clearing the selections if the moove is to row 1.
private void gridDataBoundGrid1_CurrentCellMoved(object sender, GridCurrentCellMovedEventArgs e)
{
	if(this.gridDataBoundGrid1.CurrentCell.RowIndex == 1)
		this.gridDataBoundGrid1.Selections.Clear();
}

            


AD Administrator Syncfusion Team March 30, 2005 11:44 AM UTC

This works, but after the filter is changed I would like to select the first data row of the grid. I have used the FilterBar_TextChanged event handler. I have tried to move the current cell but this had no effect (current cell stays at the filter bar cell). I also found out that the grid is not changed according to the changed row filter at the time of this handler. When is the gird updated? The following code just works graphically because the grid is not in an updated state (filter) in the Model_SelectionChanging handler. > this.gridDataBoundGrid1.Selections.Add(GridRangeInfo.Row(2)); Br, Matt


AD Administrator Syncfusion Team March 30, 2005 02:01 PM UTC

Instead of CurrentcellMoved, try handling CurrentCellCloseDropDown.
private void gridDataBoundGrid1_CurrentCellCloseDropDown(object sender, Syncfusion.Windows.Forms.PopupClosedEventArgs e)
{
	if(this.gridDataBoundGrid1.CurrentCell.RowIndex == 1)
	{
		this.gridDataBoundGrid1.Selections.Clear();
		this.gridDataBoundGrid1.CurrentCell.ConfirmChanges();
		if(this.gridDataBoundGrid1.Model.RowCount > 1)
		{
			int col = this.gridDataBoundGrid1.CurrentCell.ColIndex;
			this.gridDataBoundGrid1.CurrentCell.MoveTo(2, col);
		}
	}
}


AD Administrator Syncfusion Team March 30, 2005 03:08 PM UTC

This is the right event ;) Thx for help!

Loader.
Up arrow icon