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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Highlight a row

Thread ID:

Created:

Updated:

Platform:

Replies:

16304 Jul 12,2004 12:38 PM UTC Jul 12,2004 02:42 PM UTC WinForms 3
loading
Tags: GridControl
Christian Martel
Asked On July 12, 2004 12:38 PM UTC

I want to highlight rows in a gridControl. When I click on a button I set the backcolor property of the selected row to the color selected on the button. Everything was working fine but I added a background image to the grid and the backcolor can''t be used anymore. What can I do? I''m using vb.net.

Administrator [Syncfusion]
Replied On July 12, 2004 01:15 PM UTC

What happens if you add the row to the grid''s Selections collection: grid.Selections.Add(GridRangeInfo.Row(someRowIndex)) Normally, this would tell the grid to draw an alphablended selection rectangle over the row, and would not affect the background image.

Christian Martel
Replied On July 12, 2004 01:28 PM UTC

Sorry, I weren''t clear enough. This is not what I wanted to do. I have three different status for the lines of the grid : Normal(no change to backcolor),Overtime(backcolor blue), Overtime payed(backcolor orange). Each status has a button and when the user clicks on it the selected line''s backcolor changes. The problem here is that I added two background images on parts of the grid and I want to be able to apply those colors even on the background images. Thank you.

Administrator [Syncfusion]
Replied On July 12, 2004 02:42 PM UTC

You could handle the DrawCell event, and do all the drawing yourself. This would mean filling the background and drawing the text. If you only have TextBox cells, then this would not be a lot of work as you can use the GridStaticCellRenderer.DrawText method to manage the drawing of the text for you. But if you have several different CellTypes, then this may become cumbersome. Another solution not exactly what you have now, but maybe close enough, woul dbe to handle teh CellDrawn. There is e.RowIndex points to one of your special colored cells, you could just fill a rectangle over the cell will a mostly transparent color using alphablending. This would work not matter what the cell type was. Here is a sample handler to give you the idea.
private void gridControl1_CellDrawn(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellEventArgs e)
{
	if(e.RowIndex == 2 && e.ColIndex > 0)
	{
		using(Brush br = new SolidBrush(Color.FromArgb(60, Color.Orange)))
		{
			e.Graphics.FillRectangle(br, e.Bounds);
		}
	} 
	else if(e.RowIndex == 5 && e.ColIndex > 0)
	{
		using(Brush br = new SolidBrush(Color.FromArgb(60, Color.Blue)))
		{
			e.Graphics.FillRectangle(br, e.Bounds);
		}
	}
}

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.

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

;