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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridListControl and CheckBox

Thread ID:

Created:

Updated:

Platform:

Replies:

49605 Sep 21,2006 04:49 PM UTC Sep 22,2006 12:45 PM UTC WinForms 2
loading
Tags: GridControl
dmitry
Asked On September 21, 2006 04:49 PM UTC

I have one column with ''''CheckBox'''' typy in my GridListControl. I can see a checkbox image in a list but I cannot change the status of it. If checkbox is checked I cannot uncheck it. Below is a code what I use:

gridListControl1.Grid.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(Model_QueryCellInfo);
gridListControl1.Grid.TableStyle.CheckBoxOptions = new GridCheckBoxCellInfo(true.ToString(), false.ToString(), "", true);

void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if ((e.RowIndex > 0) && (e.ColIndex == 1))
{
e.Style.CellType = "CheckBox";
e.Style.CellValueType = typeof(bool);
e.Style.CheckBoxOptions = new GridCheckBoxCellInfo(true.ToString(), false.ToString(), "", true);
e.Style.ReadOnly = false;
e.Style.CellValue = true;
e.Style.TriState = false;
}
}

How can I make checkbox status changable?

Administrator [Syncfusion]
Replied On September 22, 2006 05:57 AM UTC

Hi Dmitry,

The data displayed in the GridListControl will be readlony. Therefore, you will not be able to click on the checkbox to change its state.

To edit the contents in the dropdown, please try using the grid in a DropDown as shown in the DropDownGrid sample.

C:\Program Files\Syncfusion\Essential Studio\4.2\Windows\Grid\Samples\In Depth\DropDownGrid sample

To make the dropdown grid look exactly like a GridListControl, please refer the KB article link below.

http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=118

Thanks for using Syncfusion Products.
Regards,
Rajagopal

Administrator [Syncfusion]
Replied On September 22, 2006 12:45 PM UTC

Hi Dmitry,

Sorry for the inconvenience caused.
One way to get the desired behavior is to store the cell value in a HashTable with rowindex as the key and retrieve it in the QueryCellInfo event to provide the cellvalues dynamically. Please try the below code snippet.

// Form_Load
this.gridListControl1.Grid.TableStyle.CheckBoxOptions = new GridCheckBoxCellInfo(true.ToString(), false.ToString(), "", true);

this.gridListControl1.Grid.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(Model_QueryCellInfo);
this.gridListControl1.Grid.CheckBoxClick += new GridCellClickEventHandler(Grid_CheckBoxClick);
//

Hashtable chkValue = new Hashtable();
private void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if(e.RowIndex > 0 && e.ColIndex == 3)
{
e.Style.CellType = "CheckBox";
e.Style.CellValueType = typeof(bool);
e.Style.CheckBoxOptions.CheckedValue = "true";
e.Style.CheckBoxOptions.UncheckedValue = "false";
e.Style.CheckBoxOptions = new GridCheckBoxCellInfo(true.ToString(), false.ToString(), "", true);
e.Style.Enabled = true;

object obj = e.Style.CellValue;
if(obj != null)
{
object val = chkValue[e.RowIndex];
if(val != null)
e.Style.CellValue = val;
}
}
}

private void Grid_CheckBoxClick(object sender, GridCellClickEventArgs e)
{
if(e.RowIndex > 0 && e.ColIndex == 3)
{
object val = this.gridListControl1.Grid[e.RowIndex, e.ColIndex].CellValue;
if(val != null)
{
bool checkValue = (bool) val;
chkValue[e.RowIndex] = !checkValue;
}
}
}

Let me know if this helps for you.
Regards,
Rajagopal

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

;