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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridControl: Changing selection in virtual tree.

Thread ID:





17416 Aug 9,2004 01:15 AM UTC Aug 9,2004 06:11 AM UTC WinForms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On August 9, 2004 01:15 AM UTC

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 06:11 AM UTC

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;


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon