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.

Problems in changing row''s background color within gridcontrol

Thread ID:

Created:

Updated:

Platform:

Replies:

90669 Oct 13,2009 03:54 AM Oct 15,2009 09:39 AM Windows Forms 8
loading
Tags: GridControl
Allon
Asked On October 13, 2009 03:54 AM

Hi, everyone

I have little problem in changing the background of rows in grid control. At the beginning I looped through the grid's rows and did ->
If t Mod 2 = 0 Then grdNew.RowStyles(t).BackColor = Yellow
Else grdNew.RowStyles(t).BackColor = White End If

then I tried to loop:

If t Mod 2 = 0 Then grdNew.RowStyles(t).BackColor = Purple
Else grdNew.RowStyles(t).BackColor = Orange End If

and nothing happened (rows remained yello and white).

Please let me know if there anything I can do about it.

Thanks in advance and have a nice day :)
Allon

Rajadurai C [Syncfusion]
Replied On October 13, 2009 10:21 AM

Hi Allon,

Thanks for your interest in Syncfusion Products.

The provided code works fine in our side. Can you please provide details about the version you are using and code settings if any, handled alongwith in your application. It would be fine for us to see the issue and work to provide a solution for it.

Regards,
Rajadurai

Allon
Replied On October 13, 2009 10:40 AM

Hello again

I use:
Microsoft Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727 SP2

Installed Edition: Professional

Essential Studio 7.3.0.20 (Ver number of Syncfusion).

Hopping it will help in something.

Regards,
Allon

Allon
Replied On October 14, 2009 05:36 AM

If it'd help you to explain and solve my problem, I suggest you to send me a little app (with environment similar to mine) with the right solution.

Have a nice day :)
Allon

Rajadurai C [Syncfusion]
Replied On October 14, 2009 10:18 AM

Hi Allon,

Thanks for your details.

Herewith i have attached a sample for your reference with the code you provided .
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/F90669.zip

In this sample, the first code snippet is handled in Form() constructor and second code snippet is handled in button click event in order to see the difference in grid while applying color settings.

Regards,
Rajadurai

Allon
Replied On October 15, 2009 03:18 AM

Thanks, but the link does not work.

I think that my problem was that I wrote:

Private Sub grdNew_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs) Handles grdNew.PrepareViewStyleInfo
If e.RowIndex > 0 And e.ColIndex > 0 Then
If e.RowIndex Mod 2 = 0 Then
e.Style.BackColor = myColors.AlternateColor
End If
End If
End Sub

and I couldn't rid of it.

Regards,
Allon

Rajadurai C [Syncfusion]
Replied On October 15, 2009 07:50 AM

Hi Allon,

Thanks for your update.

The link provided in my previous update works fine. Regarding the issue with backcolor, if you are setting backcolor for certain rows in grid through PrepareViewStyleInfo event, then you cannot overwrite those cells with other colors through some other means. The PrepareViewStyleInfo event get triggered each time the style setting of a cell is queried.

One thing you can try to achieve setting different color at runtime is, supply the colors through custom properties and set them in PrepareViewStyleInfo event.

Please refer to the following sample in which this has been achieved. By clicking the button, you can apply different set of colors.
F90669.zip

Regards,
Rajadurai

Allon
Replied On October 15, 2009 09:38 AM

Hi, Rajadurai

Thanks a lot for your quick and efficient reply. That was really helpful.

Have a nice day :)
Allon

Rajadurai C [Syncfusion]
Replied On October 15, 2009 09:39 AM

Hi Allon,

Thanks for your update.

Regards,
Rajadurai

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.

;