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 a row when mouse moves over the row

Thread ID:

Created:

Updated:

Platform:

Replies:

39142 Dec 28,2005 08:53 PM Dec 30,2005 08:30 AM Windows Forms 3
loading
Tags: GridControl
Eric Weber
Asked On December 28, 2005 08:53 PM

I''m using a GridDataBoundGrid, and I''m trying to get the background color of a row to change when the mouse is over that row. The row is not currently selected yet, just being hovered over. First I tried this... private void Grid_MouseMove(object sender, MouseEventArgs e) { bool validCell; int col, row; validCell = this.PointToRowCol(new Point(e.X, e.Y), out row, out col); if (validCell && row > 0) { this.Model.RowStyles[row].BackColor = Color.LightGoldenrodYellow; } } But that didn''t work, so I tried this.... private void Grid_MouseMove(object sender, MouseEventArgs e) { bool validCell; int col, row; validCell = this.PointToRowCol(new Point(e.X, e.Y), out row, out col); if (validCell && row > 0) { mouseOverRow = row; } } private void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e) { if (e.RowIndex == mouseOverRow) { e.Style.BackColor = Color.LightGoldenrodYellow; } else { e.Style.ResetBackColor(); } } that didn''t work either because PrepareViewStyleInfo only fires once. Help!

Administrator [Syncfusion]
Replied On December 28, 2005 11:54 PM

Hi Eric, Here is a sample which uses CellHitTest event and PrepareViewStyleInfo event to change the back color of the mouse hovering row. Regards, Calvin.

39142.zip

Eric Weber
Replied On December 29, 2005 12:12 PM

Thanks Calvin, that''s exactly what I was looking for. I see one side effect however, and was wondering you might have a work around. I''m sending you back your sample with some slight mods.... 1. In generate table... this.gridDataBoundGrid1.Model.ColStyles["Address"].WrapText = true; this.gridDataBoundGrid1.Model.ColStyles["Address"].AutoSize = true; 2. In Form load... this.gridDataBoundGrid1.Model.RowHeights.ResizeToFit(GridRangeInfo.Table()); After you run the sample... 1. resize the window so that you can see the entire grid 2. click in the cell at row 1, column 3 (the long address) 3. now move your mouse down to another row 4. Do you see how the cell you clicked on repaints itself continusously? Any ideas? Thanks!!!

39142_with_row_resize.zip

stanleyj [Syncfusion]
Replied On December 30, 2005 08:30 AM

Hi Eric, Calling Refresh in CellHitTest repaints itself continuously. This is an another try, see if this helps. In this, the current cell is moved with the mouse cursor so as to highlight based on the row that has current cell and while editing, the current cell is locked and released in next cell click. Here is the sample. Best regards, Stanley

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.

;