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

databoundGrid column Toggle button

Thread ID:





49297 Sep 15,2006 07:31 AM UTC Sep 15,2006 09:31 AM UTC WinForms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On September 15, 2006 07:31 AM UTC

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?

Stelios Halkiotis

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

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 ;
state = ButtonState.Normal;

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.

Let me know if this helps.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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