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.

Leave nodes in hierarchical databound grid

Thread ID:

Created:

Updated:

Platform:

Replies:

3486 Mar 23,2003 08:14 AM Mar 24,2003 04:34 AM Windows Forms 2
loading
Tags: GridControl
Herman Muys
Asked On March 23, 2003 08:14 AM

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 01:52 PM

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
			}
			else
			{
				this.gridDataBoundGrid1.BeginUpdate();
				this.gridDataBoundGrid1.Model.SuspendChangeEvents();
				this.gridDataBoundGrid1.ExpandAtRowIndex(e.RowIndex);
				count = state.ChildCount ;
				this.gridDataBoundGrid1.CollapseAtRowIndex(e.RowIndex);
				this.gridDataBoundGrid1.Model.ResumeChangeEvents();
				this.gridDataBoundGrid1.EndUpdate();
			}
			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 04:34 AM

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

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.

;