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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Leave nodes in hierarchical databound grid

Thread ID:





3486 Mar 23,2003 01:14 PM UTC Mar 24,2003 09:34 AM UTC WinForms 2
Tags: GridControl
Herman Muys
Asked On March 23, 2003 01:14 PM UTC

Hello, I want to use a databound grid to navigate a hierarchical tree. When I know that I am on a leave node (current record has no child records), I want to display an 'empty' bitmap in the GridDataBoundRowExpandCell control in stead of a '+' or '-' bitmap. Any idea's? Herman

Administrator [Syncfusion]
Replied On March 23, 2003 06:52 PM UTC

There may be a better way to handle this. but here is one way. You can use the DrawCellEvent, and draw this cell yourself. In your code, you would need to check for any childrows for the node, and draw the cell if there are none. One technical problem is that the childrows are not known until the node is expanded. To handle this, you can do a 'blind' expand using BeginUpdate/EndUpdate. Here is a try at this.
private void gridDataBoundGrid1_DrawCell(object sender, GridDrawCellEventArgs e)
	if( e.ColIndex == 1)
		GridBoundRecordState state = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(e.RowIndex);
		if( state.HasChildList && state.ChildCount == 0)
			int count;
			if (state.Position >= state.Table.Count)
				count = 0; //addnew row
				count = state.ChildCount ;
			if(count == 0)
				using(SolidBrush brush = new SolidBrush(e.Style.BackColor))
					e.Graphics.FillRectangle(brush, e.Bounds);
					e.Cancel = true;

Herman Muys
Replied On March 24, 2003 09:34 AM UTC

Why I couln't find this myself? Thanks, Herman


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