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.
Unfortunately, activation email could not send to your email. Please try again.

Highlighting Row with keypress

Thread ID:

Created:

Updated:

Platform:

Replies:

25513 Feb 28,2005 07:51 PM Mar 30,2005 10:08 AM Windows Forms 12
loading
Tags: GridControl
Daniel Byers
Asked On February 28, 2005 07:51 PM

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 :)

Administrator [Syncfusion]
Replied On February 28, 2005 08:27 PM

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);
}

Daniel Byers
Replied On March 28, 2005 09:24 PM

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.

Administrator [Syncfusion]
Replied On March 29, 2005 04:29 AM

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.

Administrator [Syncfusion]
Replied On March 29, 2005 10:40 AM

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

Administrator [Syncfusion]
Replied On March 29, 2005 10:46 AM

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.

Administrator [Syncfusion]
Replied On March 29, 2005 12:05 PM

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

Administrator [Syncfusion]
Replied On March 29, 2005 12:32 PM

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;
}

Administrator [Syncfusion]
Replied On March 30, 2005 02:41 AM

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

Administrator [Syncfusion]
Replied On March 30, 2005 04:10 AM

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();
}
 

Administrator [Syncfusion]
Replied On March 30, 2005 06:44 AM

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

Administrator [Syncfusion]
Replied On March 30, 2005 09:01 AM

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);
		}
	}
}

Administrator [Syncfusion]
Replied On March 30, 2005 10:08 AM

This is the right event ;) Thx for help!

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;