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.

Questions regarding cell highlight and cell location of the GridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

22024 Dec 1,2004 12:47 PM Dec 2,2004 01:27 PM Windows Forms 8
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On December 1, 2004 12:47 PM

Hi, I have 2 questions regarding the Syncfusion GridControl. 1. When changes are saved, the grid is wiped out and reloaded fresh. The currently selected row index is saved as well. When the grid finishes reloading, I''d like to dynamically highlight the previously selected row index (the selection mode = SelectionMode.One) so that the user know exactly which row she is working on. This doesn''t seem to work: grid.CurrentCell.MoveTo(withholdGridIndex, 1, Syncfusion.Windows.Forms.Grid.GridSetCurrentCellOptions.ScrollInView) -OR- grid.Selections.SelectRange(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Row(prevRowIndex), True) 2. My grids have several columns. Some of them are hidden. When the user right click on certain cell in the grid, I''d like to find the exact colIndex and rowIndex of that cell. This piece of code doesn''t seem to work (it gives me the incorrect row and col): Dim clickPoint As Point = grid.PointToClient(Cursor.Position) Dim row, col As Integer If (grid.PointToRowCol(clickPoint, row, col, -1)) Then Me.EditGridEntry(grid, row, col) TIA

Administrator [Syncfusion]
Replied On December 1, 2004 12:51 PM

Oh I left out one important detail: the previous selected row index is determined by calling: prevRowIndex = CurrentCell.RowIndex()

Administrator [Syncfusion]
Replied On December 1, 2004 01:24 PM

For 1) make sure the grid has focus before calling grid.CurrentCell.MoveTo by by calling grid.Focus. For 2, try using this method with the last parameter true. this.gridControl1.ViewLayout.PointToClientRowCol(pt, out row, out col, true);

Administrator [Syncfusion]
Replied On December 1, 2004 04:06 PM

Hi Clay, 1) The selection seems to work okay except for one thing: The highlight is not shown on the grids. (These grids are on different tabs). 2) I''ve tried this.gridControl1.ViewLayout.PointToClientRowCol(pt, out row, out col, true); I got an error saying this function is obsolete. I used grid.ViewLayout.PointToClientRowCol(clickPoint, out row, out col, true, Syncfusion.Windows.Forms.Grid.GridCellSizeKind.ActualSize) >For 1) make sure the grid has focus before calling grid.CurrentCell.MoveTo by by calling grid.Focus. > >For 2, try using this method with the last parameter true. > >this.gridControl1.ViewLayout.PointToClientRowCol(pt, out row, out col, true);

Administrator [Syncfusion]
Replied On December 1, 2004 04:07 PM

Hi Clay, Thanks for the quik response. 1) The selection seems to work okay except for one thing: The highlight is not shown on the grids. (These grids are on different tabs). 2) I''ve tried this.gridControl1.ViewLayout.PointToClientRowCol(pt, out row, out col, true); I got an error saying this function is obsolete. I used grid.ViewLayout.PointToClientRowCol(clickPoint, out row, out col, true, Syncfusion.Windows.Forms.Grid.GridCellSizeKind.ActualSize) instead and it gave me the correct column, but not the row. >For 1) make sure the grid has focus before calling grid.CurrentCell.MoveTo by by calling grid.Focus. > >For 2, try using this method with the last parameter true. > >this.gridControl1.ViewLayout.PointToClientRowCol(pt, out row, out col, true);

Administrator [Syncfusion]
Replied On December 1, 2004 05:48 PM

1) Here is a little sample for 1. If you have ListBoxSelectionMode set to One, then using CurrentCell.MoveTo seems to select the row even if the grid is on a tab that is not visible. Does this sample work for you? WindowsApplication10_6955.zip 2) grid.PointToRowCol should return the absolute row/col count in grid, including hidden cols/rows. grid.ViewLayout.PointToClientRowCol should return the row/col index among only theh visible rows/cols. This means that if 5 rows are scrolled off the top, and you click the first scrollable visible row, grid.PointToRowCol should return 6 and grid.ViewLayout.PointToClientRowCol should return 1. If you have any hidden rows among the 5 rows off the screen, the value return by either of these methods would not change. Is this not what you are seeing? Can you post a little sample project showing the problem you are seeing?

Administrator [Syncfusion]
Replied On December 2, 2004 01:03 PM

Hi Clay, 1) Thanks a lot for the sample. It is very helpful. I was able to find out what causes the highlight not to show. In my grid SelectionChanging event, I killed it with the statement e.Cancel = true. It now works nicely. 2) Okay, I''d like to display the context menu upon a right click private void Handles_GridMouseDown(object sender, System.Windows.Form.MouseEventArgs e) { if(e.Button = MouseButtons.Right) { Point clickPoint = grid.PointToClient(Cursor.Position) this.PopupMenu.Show(grid, clickPoint) } } When the user click a menu item (for example "Edit Record"), I''d like to be able to determine which row/col that she is pointing at and retrieve that record. I tried both functions PointToRowCol but neither one gave me the correct answer for some reason. Should I use the "CurentCell.MoveToRowIndex" and "CurrentCell.MoveToColIndex"?? private void Handles_EditMenuItemClicked(object sender, System.EventArgs e) { Point clickPoint = grid.PointToClient(Cursor.Position) int row, col; grid.ViewLayout.PointToClientRowCol(clickPoint, out row, out col, true, Syncfusion.Windows.Forms.Grid.GridCellSizeKind.ActualSize) //Or grid.PointToRowCol(clickPoint, row, col, -1) this.EditGridEntry(row, col) } Thanks, Khoi

Administrator [Syncfusion]
Replied On December 2, 2004 01:11 PM

You generally have to remember the clickpoint in form members as teh mouse may move when teh user selects from a long menu. Did you see the sample in this thread. It shows one way to do this. http://64.78.18.34/Support/Forums/message.aspx?MessageID=22047

Administrator [Syncfusion]
Replied On December 2, 2004 01:27 PM

Thanks Clay, Everything now works nicely the way it''s supposed to. Khoi.

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.

;