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.

Initialize the Grid Tree Control

Thread ID:





93292 Mar 8,2010 09:16 PM Mar 11,2010 07:39 AM WPF 3
Tags: GridControl
Asked On March 8, 2010 09:16 PM

I have a question about the Grid Tree Control

When initialize the Grid Tree Control. It seems I need to get three levels' data. It is too inefficient for our project.

I hope only get the data of highest level when initialize(it look like collapse all nodes)

please see the Attachment

Initialize Grid Tree Control _b6ff31f9.rar

Clay Burch [Syncfusion]
Replied On March 9, 2010 07:56 AM

By default, the GridTreeControl loads one level in advance so it knows whether the displayed children need to have an expand glyph or not. There is a HideEmptyChilGlyph property that controls this behavior.

Also, by default, the GridTreeControl displays with the root nodes expanded. To avoid this behavior, you need to set a property on the gridTreeControl.InternalGrid. To set such properties requires that you handle the ModelLoaded event and set the properties in that event (since the InternalGrid has been created when this event is raised).

So, try code like this in that sample to see if it does what you want:

public Window1()

//one time, initialize the data access some how...
employees = new EmployeesCollection();

treeGrid.ModelLoaded += new EventHandler(treeGrid_ModelLoaded);
treeGrid.HideEmptyChildGlyphs = false; }

void treeGrid_ModelLoaded(object sender, EventArgs e)
treeGrid.InternalGrid.ExpandStateAtStartUp = GridTreeStartUpExpandState.NoNodesExpanded;

Replied On March 11, 2010 05:13 AM

Thanks very much for the respond.

I have another question.

Does the GridTreeControl has the ResizingColumns event,because i hope to cancel the default resizing and auto-size it through the "ResizeColumnsToFit" method

Clay Burch [Syncfusion]
Replied On March 11, 2010 07:39 AM

There are a couple of properties specific to the GridTreeControl that affect column widths. The AllowAutoSizingNodeColumn property controls whether the GridTreeControl automatically increases the size of the treenode columns as more levels are exposed. There is also a PercentSizingBehaviorProperty that controls how the GridTreeControl can be set so its columns automatically cover all of the grid's client area.

If you want to make it impossible for your user to size columns through the UI, then you can handle treeGrid.InternalGrid.ResizingColumns event. Below is some code showing how you might set these properties and subscribe to this event in the ModelLoaded event.

void treeGrid_ModelLoaded(object sender, EventArgs e)
treeGrid.InternalGrid.ExpandStateAtStartUp = GridTreeStartUpExpandState.NoNodesExpanded;

treeGrid.PercentSizingBehavior = GridPercentColumnSizingBehavior.None;
treeGrid.AllowAutoSizingNodeColumn = false;

treeGrid.InternalGrid.ResizingColumns += new GridResizingColumnsEventHandler(InternalGrid_ResizingColumns);

void InternalGrid_ResizingColumns(object sender, GridResizingColumnsEventArgs args)
args.AllowResize = false;


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.