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.

databoundGrid column Toggle button

Thread ID:

Created:

Updated:

Platform:

Replies:

49297 Sep 15,2006 03:31 AM Sep 15,2006 05:31 AM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On September 15, 2006 03:31 AM

Hi.
I need to have the cells of a column to be displayed as toggle buttons. The cells display a boolean value, so i want to have the button pressed for true and not pressed for false.

Does anybody knows how can i do this?

Thanks
Stelios Halkiotis

Administrator [Syncfusion]
Replied On September 15, 2006 05:31 AM

Hi Stelios,

You would have to derive the GridStaticCellRenderer and override these methods.

protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style)
{
bool b = false;
ButtonState state = ButtonState.Pushed;
if( style.CellValue != null && style.CellValueType == typeof(bool))
{
b = (bool) style.CellValue ;
if(b)
{
state = ButtonState.Normal;
}
}
ControlPaint.DrawButton(g,clientRectangle,state);
}

protected override void OnClick(int rowIndex, int colIndex, MouseEventArgs e)
{
base.OnClick (rowIndex, colIndex, e);
bool b = (bool)this.Grid.Model[rowIndex,colIndex].CellValue;
this.Grid.Model[rowIndex,colIndex].CellValue =!b;
this.Grid.RefreshRange(GridRangeInfo.Cell( rowIndex,colIndex));
}

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/ToggleButtonCell_12ad16e3.zip

Let me know if this helps.

Thanks,
Haneef

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.

;