How to change the BackgroundColor of a XtraGrid Grouprow using C# or VB.NET

To change the BackgroundColor of a XtraGrid Grouprow you need to use the Gridviews CustomDrawGroupRow Event.

Sample C#

private void gridView1_CustomDrawGroupRow(object sender, RowObjectCustomDrawEventArgs e)
{
	var converter = new ColorConverter();
	var convertFromString = converter.ConvertFromString("#ebebeb");
	if (convertFromString != null)
	{
		e.Appearance.BackColor = (Color) convertFromString;
	}
}

Sample VB.NET

Private Sub gridView1_CustomDrawGroupRow(sender As Object, e As RowObjectCustomDrawEventArgs)
	Dim converter = New ColorConverter()
	Dim convertFromString = converter.ConvertFromString("#ebebeb")
	If convertFromString IsNot Nothing Then
		e.Appearance.BackColor = DirectCast(convertFromString, Color)
	End If
End Sub

Please rate this snippet

How to get a random Color in C# and VB.NET

To get a random Color in C# and VB.NET you can use the following snippet.

Sample C#

public static System.Drawing.Color RandomColor()
{
	var rand = new Random();
	var r = rand.Next(0, 256);
	Thread.Sleep(1);
	var g = rand.Next(0, 256);
	Thread.Sleep(1);
	var b = rand.Next(0, 256);
	return System.Drawing.Color.FromArgb(255, r, g, b);
}

Sample VB.NET

Public Shared Function RandomColor() As System.Drawing.Color
	Dim rand As var = New Random
	Dim r As var = rand.Next(0, 256)
	Thread.Sleep(1)
	Dim g As var = rand.Next(0, 256)
	Thread.Sleep(1)
	Dim b As var = rand.Next(0, 256)
	Return System.Drawing.Color.FromArgb(255, r, g, b)
End Function

Please rate this snippet

How to choose a color using ColorDialog in C# and VB.NET

To choose a color using ColorDialog in C# and VB.NET you can use the following snippet.

Sample C#

using (var colorDialog = new ColorDialog())
{
	if (colorDialog.ShowDialog() != DialogResult.Cancel)
	{
		var colorChosen = colorDialog.Color;
		textBox1.ForeColor = colorChosen;
		textBox1.BackColor = colorChosen;
	}
}

Sample VB.NET

Using colorDialog = New ColorDialog()
	If colorDialog.ShowDialog() <> DialogResult.Cancel Then
		Dim colorChosen = colorDialog.Color
		textBox1.ForeColor = colorChosen
		textBox1.BackColor = colorChosen
	End If
End Using

Please rate this snippet

How to create zebra table effect with jQuery and CSS

To create zebra table effect with jQuery and CSS you can use the following snippet.

jQuery

$("tr:odd").addClass("oddRowsEffect");

in the css you need something like

tr.oddRowsEffect{
/* background: choose a color; *
/* color: choose a color; *
}

Please rate this snippet