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

Cells Colors

Thread ID:





8421 Nov 5,2003 02:43 PM UTC Nov 5,2003 07:13 PM UTC WinForms 4
Tags: GridControl
Asked On November 5, 2003 02:43 PM UTC

I have created a GridDataBound and it's data source i chose a DataTable . now , each time I add something to the DataTable it also appears on the GridDataBound . my problem is like this , I wanna change the background of one or more rows , or if that is not possible I wanna change cells colors . I tried changing the color of the cells like this : gridDataBound1 [ 1 , 1 ].BackColor = Color.Aqua but it won't change it ... why is that ? and how can I change a whole row or at least one cell . thanks for the help .

Administrator [Syncfusion]
Replied On November 5, 2003 03:06 PM UTC

There are a couple of KB articles that discuss how to do this. http://www.syncfusion.com/KB/Grid/Grid_c35c.asp#q560q http://www.syncfusion.com/KB/Grid/Grid_c35c.asp#q561q

Replied On November 5, 2003 03:29 PM UTC

but how do I call this function , it is an event and not a function . i want a function that recevies a primary key in the DataTable and changes the row color in the GridDataBound . please help me ...

Administrator [Syncfusion]
Replied On November 5, 2003 04:14 PM UTC

You cannot call a function and change the color of a row in a GridDataBoundGrid. The reason is that there no properties stored on a row basis in a GridDataBoundGrid. Instead, you must listened for the PrepareViewStyleInfo event. There, if e.RowIndex and e.ColIndex point to a cell that you want to color, you should set e.Style.BackColor to the desired color. (This way, there is never any color saved for a particular cell or row. It is always provided on demand through this event). You can use grid.Binder.NameToColIndex to find out the column index for your key column. Attached is a little sample that colors any row whose 'primary key' value is divisible by 4.

Replied On November 5, 2003 07:13 PM UTC

well , ok thanks I will try it tommorow at work and see if it works .


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