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.

Grid Data Bound Grid - Columns Format

Thread ID:

Created:

Updated:

Platform:

Replies:

5541 Jul 8,2003 04:09 AM Jul 9,2003 06:48 AM Windows Forms 6
loading
Tags: GridControl
Eli Smadar
Asked On July 8, 2003 04:09 AM

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 04:43 AM

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 05:15 AM

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 06:03 AM

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 06:19 AM

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 10:51 AM

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 06:48 AM

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

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.

;