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.

Selecting all cells in a merged region

Thread ID:

Created:

Updated:

Platform:

Replies:

21310 Nov 6,2004 12:43 PM Nov 7,2004 05:22 AM Windows Forms 6
loading
Tags: GridControl
vbaker
Asked On November 6, 2004 12:43 PM

In a GridControl, is there a way to cause all cells within a merged region to become selected with a single click so that the merged region can then be dragged and dropped? --Van Baker

Administrator [Syncfusion]
Replied On November 6, 2004 02:49 PM

By merge, you mean MergeCells and not coveredcells, correct? There are no property settings to handle this. One want you can do this is to handle the QueryOleDataSourceData event and set the e.DataObject yourself to hold what cells you want to drag. You would create a string delimited by tab for columns and NewLines for rows, and set the string into the dataobject, also setting e.Handled = true and e.Result = true. Another option would be to handle the CurrentCellMoved event. And there you could add a range to grid.Selections that holds a range of cells that you want to possibly drag.

vbaker
Replied On November 6, 2004 03:51 PM

Thanks, Clay, for your reply. Yes, I do mean merged cells, not covered. I haven''t yet tried your first option, but have tried something similar to your second. I handled MouseDown as follows to isolate the merged cell range: if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { Point pt = this.gridControl1.PointToClient(Control.MousePosition); if (this.gridControl1.PointToRowCol(pt, out Row, out Col)) { this.gridControl1.CurrentCell.AdjustRowColIfCoveredCell(ref Row, ref Col); } //Determine if the clicked cell is part of a MergeCell range GridRangeInfo gri = this.gridControl1.Model.MergeCells.FindRange(Row, Col); if (!gri.IsEmpty) { // Yes, it''s part of a MergeCell range. Select the entire range. this.gridControl1.Selections.SelectRange(gri, true); } } When I click on a cell in a merged range, the entire merged range does, in fact, "appear" selected. However, there is now a "focus" rectangle around the clicked cell, and if I attempt to drag at that point, only the focused cell will drag. In order to select the entire range for dragging, I have to click/drag the mouse over the range of cells, which now appear with a slightly different selection color. It is like there are two different types of "selection", one which will drag, the other which will not, which admittedly, I don''t seem to understand. --Van Baker

Administrator [Syncfusion]
Replied On November 6, 2004 04:04 PM

Try your code in CurrentCellMoved. In the handler, you can try testing for mousedown using the static member, Control.MouseButtons.

vbaker
Replied On November 6, 2004 04:48 PM

I tried your suggestion handling CurrentCellMoved with my code, but still, only the clicked cell will drag. I have to manually re-select the entire range and then drag in order for the entire range to move. Should I be using Covered Cells rather than MergeCells? If so, how to combine multiple cells based on their content? --Van Baker

Administrator [Syncfusion]
Replied On November 7, 2004 01:39 AM

Try your code in MouseUp but first deactivate the currentcell.
private void gridControl1_MouseUp(object sender, MouseEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	GridRangeInfo gri = this.gridControl1.Model.MergeCells.FindRange(cc.RowIndex, cc.ColIndex);
	if (!gri.IsEmpty)
	{
		cc.Deactivate(false);
		this.gridControl1.Selections.SelectRange(gri, true);
	} 
}

vbaker
Replied On November 7, 2004 05:22 AM

Thank you! I appreciate your patience and persistence. That accomplishes exactly what I needed. --Van Baker

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.

;