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.
Syncfusion Feedback

GridControl properties

Thread ID:

Created:

Updated:

Platform:

Replies:

54434 Jan 9,2007 08:36 AM UTC Jan 9,2007 02:32 PM UTC Windows Forms 7
loading
Tags: GridControl
Roger
Asked On January 9, 2007 08:36 AM UTC

I am trying to set column header properties of a GridControl.
I want to get hold of the BaseStylesMap propertyinfo of the gridcontrol and set the columnheader.
i.e, i want to do something like
theGridControl.BaseStylesMap.baseStyles.ColumnHeader.Font = "Arial". Please let me know how to set these properties (using say PropertyInfo.SetValue).

The reason is because i want to store the style in an xml file say in the format
.
Then i want to read the property name from the xml file and get the corresponding property from the gridcontrol and set its style (in this case the column header)


Administrator [Syncfusion]
Replied On January 9, 2007 08:57 AM UTC

Hi Roger,

Try this code.

this.gridControl1.BaseStylesMap["Column Header"].StyleInfo.Font = new Syncfusion.Windows.Forms.Grid.GridFontInfo(new Font("Arial",14f));

Please refer to the attached sample for more details.
GridBaseStyleInfoSample.zip

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On January 9, 2007 09:05 AM UTC

Excellent. That works. Thanks for the quick response.

Rgds
Rakesh

Administrator [Syncfusion]
Replied On January 9, 2007 09:25 AM UTC

One more question..

Can we do something like
gridControl.BaseStylesMap["Column Header"].StyleInfo.Font = "Tahoma,18.25,style=Regular";

i.e.,
As i said i wanted to read a property from an xml file say do set value like
1) Get the property
PropertyInfo prop = gridControl.GetType().GetProperty("gridControl.BaseStylesMap["Column Header"].StyleInfo.Font");

2) create the font object from the font string (read from xml file)

Type type=prop.PropertyType;
Object o = RuntimeHelpers.GetObjectValue(TypeDescriptor.GetConverter(type).ConvertFromString("Tahoma,18.25,style=Regular"));

3) set the property value
prop.SetValue(gridControl, o, null);

Administrator [Syncfusion]
Replied On January 9, 2007 09:58 AM UTC

Hi Roger,

The attached sample shows you how to serialize and deserialize the grids schema information. Serialization is the process of saving the state of an object by converting it into a stream of bytes. The reverse process of serialization is deserialization. The sample demonstrates three types of serialization techniques: Soap Serialization, Binary Serialization and Xml Serialization. Please refer to the attached sample for more details.

Sample : GridSchemaSerialization.zip

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On January 9, 2007 10:47 AM UTC

Thanks. I tried xml serialisation.
After adding basestylesmap manually in code for column header in onload of the grid, I tried saving as xml as done in the sample.

But I couldnt find any info in the resultant xml file regarding the 'column header'. neither did the deserialisation retrieve the column headers.

Please advise.

Administrator [Syncfusion]
Replied On January 9, 2007 12:37 PM UTC

Hi Roger,

Sorry for the inconvenience caused. The last attached sample serialize and deserialize the grids data information with XML format. If you want to save individual style object, then you could try style.WriteXml() to see if that helps.

File s = File.Create(dlg.FileName);
XmlWriter xw = new XmlTextWriter(s, System.Text.Encoding.Default);
XmlSerializer xs = new XmlSerializer(this.gridControl1[0,1].GetType());
this.gridControl1[0,1].WriteXml(xw);
s.Close();

Use the grid[1,1].ReadXml() method to deserialize the content from Xml.

File s = File.Create(dlg.FileName);
XmlReader xw = new XmlTextReader(s);
XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(this.gridControl1[0,1].GetType());
this.gridControl1[0,1] .ReadXml(xw);
s.Close();

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On January 9, 2007 02:32 PM UTC

Thanks for the reply.

But doesnt look like basestylemap details(column header basestyle) which i added to the grid got saved in the xml file.

Say i do:
Syncfusion.Windows.Forms.Grid.GridBaseStyle gridBaseStyle = = new Syncfusion.Windows.Forms.Grid.GridBaseStyle();
gridBaseStyle1.Name = "Column Header";
gridBaseStyle1.StyleInfo.Font.Bold = true;
gridBaseStyle1.StyleInfo.Font.Facename = "Tahoma";
gridControl1.BaseStylesMap.AddRange(new Syncfusion.Windows.Forms.Grid.GridBaseStyle[] { gridBaseStyle1 });

Now when i save in xml i need this property saved. Please let me know how to do that?

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.

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

;