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.

how to customize nested table GridGroupContrl to looks like TreeView (look & feel)

Thread ID:

Created:

Updated:

Platform:

Replies:

79861 Mar 2,2009 09:29 AM Mar 4,2009 07:54 AM Windows Forms 3
loading
Tags: GridControl
David Cui
Asked On March 2, 2009 09:29 AM


hi, any example or way of customize the nested table as data sources' GGC looks like TreeView presentatio ?

best,

david


Nisha Arockiya A [Syncfusion]
Replied On March 3, 2009 07:36 AM

Hi David,

Thanks for your interest in Syncfusion Products.

You can handle TableControlDrawCell event to customise the nested Table.

Code Snippet:


void gridGroupingControl1_TableControlDrawCell(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlDrawCellEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if (style.TableCellIdentity.TableCellType == GridTableCellType.RecordPlusMinusCell
|| style.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionPlusMinusCell)
{
e.Inner.Cancel = true;
Point pt = e.Inner.Bounds.Location;
pt.Offset(e.Inner.Bounds.Width/2 -2 ,e.Inner.Bounds.Height/2 - 2);
Rectangle rect =new Rectangle(pt,new Size(9,9));
e.Inner.Graphics.DrawRectangle(Pens.Black, rect);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;

e.Inner.Graphics.DrawString(e.Inner.Style.Description, e.Inner.Style.GdipFont,new SolidBrush(e.Inner.Style.TextColor),rect,format);
}
}


Here is the sample:


http://files.syncfusion.com/samples/Grid.Windows/F79861/main.htm


Let me know if this serve your needs.

Regards,
Nisha.


David Cui
Replied On March 3, 2009 11:05 AM


Nisha,

it does work. Thanks.

but somehow, it doesn't look decent as default windows or sncfustion treeview ... , say the tree lines , ...

I am not good at graphic drawing, any other good example ?

David

>Hi David,

Thanks for your interest in Syncfusion Products.

You can handle TableControlDrawCell event to customise the nested Table.

Code Snippet:


void gridGroupingControl1_TableControlDrawCell(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlDrawCellEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if (style.TableCellIdentity.TableCellType == GridTableCellType.RecordPlusMinusCell
|| style.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionPlusMinusCell)
{
e.Inner.Cancel = true;
Point pt = e.Inner.Bounds.Location;
pt.Offset(e.Inner.Bounds.Width/2 -2 ,e.Inner.Bounds.Height/2 - 2);
Rectangle rect =new Rectangle(pt,new Size(9,9));
e.Inner.Graphics.DrawRectangle(Pens.Black, rect);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;

e.Inner.Graphics.DrawString(e.Inner.Style.Description, e.Inner.Style.GdipFont,new SolidBrush(e.Inner.Style.TextColor),rect,format);
}
}


Here is the sample:


http://files.syncfusion.com/samples/Grid.Windows/F79861/main.htm


Let me know if this serve your needs.

Regards,
Nisha.




Nisha Arockiya A [Syncfusion]
Replied On March 4, 2009 07:54 AM

Hi David,

Thanks for the Update.

Please refer to the browser sample on GDBG Tree Lines Demo in the following path.

\My Documents\Syncfusion\EssentialStudio\7.1.0.20\Windows\Grid.Windows\Samples\2.0\Data Bound\Hierarchical\GDBG Tree Lines Demo

This sample illustrates the display of a hierarchical grid with tree lines and indented text in the first column. To achieve this, you must set the GridDataBoundGrid.ShowTreeLines property to true.

Let me know if this helps.

Regards,
Nisha.


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.

;