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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid Data Bound Grid - Columns Format

Thread ID:





5541 Jul 8,2003 08:09 AM UTC Jul 9,2003 10:48 AM UTC WinForms 6
Tags: GridControl
Eli Smadar
Asked On July 8, 2003 08:09 AM UTC

I am trying to change formating of specific columns in the grid. No problem to change the TextColor but i was unable to change the backcolor and TextAlign. I tried ChangeCell and ColStyles and both have the same effect. Is there something i am doing wrong?

Administrator [Syncfusion]
Replied On July 8, 2003 08:43 AM UTC

In a GridDataBoundGrid, you should use the GridBoundColumn.StyleInfo object to set column styles. For each column, you can get this object through either from the grid.GridBoundColumns collection if you have explicitly added GridBoundColumns to your grid, or from grid.Binder.InternalColumns if you have not added them. Also, TextAlign is used to position text relative to a cell button. If you want to align text in teh cell, then use the HorizontalAlignment property instead of TextAlign. this.grid.Binder.InternalColumns["Col2"].StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Right;

Eli Smadar
Replied On July 8, 2003 09:15 AM UTC

I tried using the GridBoundColumnsColllection as well and nothing seems to help. Here is the code i am using. GridBoundColumnsCollection colCols = this.grdLines.GridBoundColumns; GridBoundColumn col; //Name col = new GridBoundColumn(); col.HeaderText = "Name"; col.MappingName = "Name"; col.ReadOnly = true; col.StyleInfo.BackColor = SystemColors.ControlLight; colCols.Add(col);

Administrator [Syncfusion]
Replied On July 8, 2003 10:03 AM UTC

Don't set ReadOnly = true until the last change. If you set it, you will not be able to programatically change the style either unless you have explicitly set grid.IgnoreReadOnly = true before you start changing things. Then later you would want to turn IgnoreReadOnly off so the column will not ignore the readonly flag.

Eli Smadar
Replied On July 8, 2003 10:19 AM UTC

The HorizontalAlign worked - Thank you. Sorry but the backcolor still not working. Could it be any setting in the grid?

Administrator [Syncfusion]
Replied On July 8, 2003 02:51 PM UTC

I think it should work. Attached is a little project where I copied and pasted your code, and it seems to work there. What is different about what you are doing?

Eli Smadar
Replied On July 9, 2003 10:48 AM UTC

Thanks Clay. I think i found the bug. If you set the background Image to something and then delete it - No more backcolor influance. When with a backgroundImage then i couldn't set the backcolor at all - why? Eli


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