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.
Syncfusion Feedback

Color selected line

Thread ID:

Created:

Updated:

Platform:

Replies:

23684 Jan 18,2005 07:02 AM UTC Feb 13,2006 05:00 AM UTC Windows Forms 6
loading
Tags: GridControl
sve
Asked On January 18, 2005 07:02 AM UTC

I want to color the selected line of a GridDataboundGrid in a particular color. I try private void gdg_CellClick(object sender, Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs e) { gdg.Model.RowStyles[e.RowIndex].BackColor = System.Drawing.Color.Red; gdg.Model.Refresh(); gdg.Refresh(); } Thanks

Administrator [Syncfusion]
Replied On January 18, 2005 07:07 AM UTC

You cannot ''set'' the backcolor of a row in a GridDataBoundGrid. Instead, you need to use an event to manage this. http://64.78.18.34/Support/article.aspx?id=561 If you always want to have the current row selected, you can set grid.ListBoxSelectionMode = SelectionMode.One. Then the selection color will be applied to the current row (as an overdrawn alphablended rectangle). You can control this alphablend color by setting grid.AlphaBlendSelectionColor.

sve
Replied On January 18, 2005 07:41 AM UTC

Ok grid.ListBoxSelectionMode = SelectionMode.One works fine. However when my rowindex change programiticaly (with a currencyManager attach to a DataTable who''s populate my grid) the row isn''t underline. Is there a special refresh to do ?

sve
Replied On January 18, 2005 07:59 AM UTC

Ok, i use and event and it works fine. Thanks. >Ok grid.ListBoxSelectionMode = SelectionMode.One works fine. However when my rowindex change programiticaly (with a currencyManager attach to a DataTable who''s populate my grid) the row isn''t underline. >Is there a special refresh to do ?

Administrator [Syncfusion]
Replied On January 18, 2005 08:10 AM UTC

You can handle the currencymanager positionchanged event. CurrencyManager cm = (CurrencyManager) this.gridDataBoundGrid1.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember]; cm.PositionChanged += new EventHandler(cm_PositionChanged); In the handler, if the position change is from outside the grid, move the currentcell.
private void cm_PositionChanged(object sender, EventArgs e)
{
	if(!this.gridDataBoundGrid1.CurrentCell.IsInMoveTo)
	{
		CurrencyManager cm = sender as CurrencyManager;
		if(cm != null)
		{
			int row = this.gridDataBoundGrid1.Binder.PositionToRowIndex(cm.Position);
			this.gridDataBoundGrid1.CurrentCell.MoveTo(row, this.gridDataBoundGrid1.CurrentCell.ColIndex);
		}
	}
}

Lev Pelekh
Replied On February 10, 2006 09:40 PM UTC

I am trying to undo the black color of the selected row in GridDataBoundGrid. I would like it to stay white. I tried setting e.Style.BackColor in the GDBG_PrepareViewStyleInfo event, but doesn''t seem to effect selected rows, they are still black. Any info would be appreciated. Lev

stanleyj [Syncfusion]
Replied On February 13, 2006 05:00 AM UTC

Hi Lev, I do not know what black color you are trying to remove. Here is a code snippet to show setting e.Style.BackColor in the PrepareViewStyleInfo event that changes for the selected rows. this.gridDataBoundGrid1.AlphaBlendSelectionColor = Color.Empty; this.gridDataBoundGrid1.ListBoxSelectionMode = SelectionMode.One; this.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways; this.gridDataBoundGrid1.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(gridDataBoundGrid1_PrepareViewStyleInfo); private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e) { GridCurrentCell cc = gridDataBoundGrid1.CurrentCell; // Highlight the current row if (e.RowIndex > gridDataBoundGrid1.Model.Rows.HeaderCount && e.ColIndex > gridDataBoundGrid1.Model.Cols.HeaderCount && cc.HasCurrentCellAt(e.RowIndex)) { e.Style.BackColor = Color.Pink; e.Style.TextColor = SystemColors.HighlightText; e.Style.Font.Bold = true; } } Best regards, Stanley

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

;