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.
Syncfusion Feedback

GridControl: Changing selection in virtual tree.

Thread ID:

Created:

Updated:

Platform:

Replies:

17416 Aug 8,2004 09:15 PM Aug 9,2004 02:11 AM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 8, 2004 09:15 PM

Hello. I have a little problem :) I implement virtual tree grid, like in the suite samples "Virtual tree grid". But, the problem is in rows selection. When I hit collapse or expand buttons, all selected rows become unselected and selection moves to the currently expanded single row. The question is: How to avoid selection changes during expand and collapse operation. The situation could be reproduced with "Virtual tree grid" sample, you should set property ListBoxSelectionMode = One Thanks.

Administrator [Syncfusion]
Replied On August 9, 2004 02:11 AM

Here is code that will prevent selection changing when you click on the left side on the tree cell. But I do not know what you want dome when you close a node above the slection. This code will leave it at the row position in the grid. If you want teh same row to remain selected, then when the node is above teh selection you will have to adjust the selected row by th enumber of rows added or removed duting teh node operation.
private void gridControl1_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{
	if(e.Reason == GridSelectionReason.SetCurrentCell && Control.MouseButtons == MouseButtons.Left)
	{
		int row, col;
		Point pt = this.gridControl1.PointToClient(Control.MousePosition);
		if(this.gridControl1.PointToRowCol(pt, out row, out col, -1)
			&& col == 1)
		{
			TreeCellRenderer cr = this.gridControl1.GetCellRenderer(row, col) as TreeCellRenderer;
			Rectangle rect = cr.GetCellBoundsCore(row, col);
			int X = 20 + rect.X + cr.IndentSize * (int)this.gridControl1[row, col].Tag;
			if( pt.X < X)
				e.Cancel = true;
		}
	}
}

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

;