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.

Alternating colors in a GridListControl

Thread ID:

Created:

Updated:

Platform:

Replies:

2378 Jan 14,2003 07:37 AM Jan 16,2003 05:26 AM Windows Forms 6
loading
Tags: GridControl
Bill
Asked On January 14, 2003 07:37 AM

How can you alternate the colors of the rows in with the GridListControl. With the .net controls there is a DrawItem property that allows you to write code to accomplish this task. Is there something similar in syncfusion. Thanks in advance. Bill

Administrator [Syncfusion]
Replied On January 14, 2003 09:22 AM

You can use the PrepareViewStyleInfo event of the embedded GridControl to handle this. //hook the event GridControl grid = gridListControl1.Grid; grid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(grid_PrepareViewStyleInfo);
//the event handler
private void grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if( e.RowIndex > 0)
	{
		if(e.RowIndex % 2 == 1)
		{
			e.Style.BackColor = Color.Blue;
		}
		else
		{
			e.Style.BackColor = Color.AliceBlue;
		}
	}
}

Bill
Replied On January 14, 2003 09:57 AM

> You can use the PrepareViewStyleInfo event of the embedded GridControl to handle this. > > > //hook the event > GridControl grid = gridListControl1.Grid; > grid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(grid_PrepareViewStyleInfo); > > > >
> //the event handler
> private void grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
> {
> 	if( e.RowIndex > 0)
> 	{
> 		if(e.RowIndex % 2 == 1)
> 		{
> 			e.Style.BackColor = Color.Blue;
> 		}
> 		else
> 		{
> 			e.Style.BackColor = Color.AliceBlue;
> 		}
> 	}
> }
> 
Clay do you have the code in VB.net? I am not familiar with C#. Thanks, Bill

Administrator [Syncfusion]
Replied On January 14, 2003 05:12 PM

Here it is. ' in form load 'hook the event Dim grid As GridControl = gridListControl1.Grid AddHandler grid.PrepareViewStyleInfo, AddressOf grid_PrepareViewStyleInfo
' the handler
'the event handler
Private Sub grid_PrepareViewStyleInfo(sender As Object, e As GridPrepareViewStyleInfoEventArgs)
    If e.RowIndex > 0 Then
        If e.RowIndex Mod 2 = 1 Then
            e.Style.BackColor = Color.Blue
        Else
            e.Style.BackColor = Color.AliceBlue
        End If
    End If
End Sub 'grid_PrepareViewStyleInfo    

Bill
Replied On January 15, 2003 07:27 AM

Clay, I get an bad Name error when I Dim grid As GridControl = gridListControl1.Grid. It does not like the GridControl namespace. Any suggestions. I am new to VB.Net so any info would be helpful. Bill

Administrator [Syncfusion]
Replied On January 15, 2003 11:10 AM

Try adding Imports Syncfusion.Windows.Forms.Grid as the first line in your file (outside the class definition).

Bill
Replied On January 16, 2003 05:26 AM

Clay, Thanks a lot. Bill

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.

;