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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Single cell selection

Thread ID:

Created:

Updated:

Platform:

Replies:

12408 Mar 29,2004 02:53 PM UTC Mar 31,2004 02:10 PM UTC WinForms 5
loading
Tags: GridControl
John Bowm
Asked On March 29, 2004 02:53 PM UTC

Hello, I just discovered that if the user of my Grid control single left clicks on a single cell (as opposed to clicking and dragging a range of cells), or uses the arrow keys to move to a particular cell, that when I check the CurrGrid.Selections.Ranges count there''s nothing selected, value = 0?! It''s like the cell is not selected. When the user selects more than one cell by either keys or mouse, then all the appropriate cells appear in the ranges list correctly. The very 1st time the user clicks on the grid, it works, but all subsequent arrowing to another cell, or clicking another cell the count is 0. BTW, I''ve got it set to only allow single selection. How can I force it to select this current cell? I''ve tried: CurrGrid.CurrentCell.Activate & CurrGrid.Selections.Add approaches and neither seem to select the current cell. My ultimate goal is to just copy any selection in the grid to the clipboard and everything else is working just great. I must be missing something obvious. TIA, John

Administrator [Syncfusion]
Replied On March 29, 2004 04:27 PM UTC

The default behavior of the grid is to not include the CurrentCell in the grid.Selections collection. This is by design. If you want to include it, one way is to set a couple of excelLike properties. this.gridControl1.ExcelLikeCurrentCell = true; this.gridControl1.ExcelLikeSelectionFrame = true; But you may or may not like the look of this as it draws a fatter selection frame that the default. If you do not want to use the excel properties, then I think you can handle a couple of events, and manually add/remove the currentcell from teh grid.Selections collection.
private void gridControl1_CurrentCellMoving(object sender, GridCurrentCellMovingEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	this.gridControl1.Selections.Remove(cc.RangeInfo);
	this.gridControl1.Selections.Add(GridRangeInfo.Cell(cc.MoveToRowIndex, cc.MoveToColIndex));
}
private void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
{
	this.gridControl1.Selections.Add(GridRangeInfo.Cell(e.RowIndex, e.ColIndex));
}

John Bowm
Replied On March 30, 2004 11:28 AM UTC

Clay, Thanks for the help. It sort of worked. Handling the CellClick event made it so when the user uses the arrow keys to move arround from cell to cell, the cell get''s selected. However, I can''t get the mouse click on a cell to work the same way. Handling CurrentCellMoving didn''t work. I''ve attached the salient excerpt of my code (MouseDown.ZIP) from the OnMouseDown event... However, if the user clicks a single cell by left clicking, then right clicks inside that cell, to bring up the context menu, the attached handler is not reliably entered at all. When it does get entered, then the line: bool brtn = CurrGrid.PointToRowCol(ptMouse, out RowIdx, out ColIdx, -1); returns false as if we did not even click inside the cell area of the control at all. Thus, no context menu. What gives? The intention here is to have the context menu come up whenever the user right clicks inside a selection and then bring up the context menu so selections can be copied to the clipboard (regardless of if the selection is 1 cell or more). Note that the grid is set up so the user cannot change any values, and dis-allows multiple selections. TIA again, John MoueDown_4033.zip

Administrator [Syncfusion]
Replied On March 30, 2004 12:49 PM UTC

When you left-click a cell, (depending upon your settings), the cell may become active with its embedded control having the input focus. At this point, the grid would no long longer get a right-mouse down event, but instead the cell control gets the mousedown. Is this the behavior you are seeing? If so, here is a sample that handles this by subscribing to the embedded controls mouse down event to catch these clicks. Here is a sample

John Bowm
Replied On March 30, 2004 12:56 PM UTC

Clay, Thanks again. Your description sounds rather similar to the behavior I''m seeing. Thanks for the sample. I''ll check it out and see if it "cures" me and let you know. John

John Bowm
Replied On March 31, 2004 02:10 PM UTC

Clay, Thanks for all the help. It seems as though I''ve got it all working rather nicely now.

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.

Warning Icon 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.Close Icon

;