GridListControl and CheckBox
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;
}
}
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;
}
}
SIGN IN To post a reply.
2 Replies
AD
Administrator
Syncfusion Team
September 22, 2006 05:59 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
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
AD
Administrator
Syncfusion Team
September 22, 2006 12:41 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);
//
Let me know if this helps for you.
Regards,
Rajagopal
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
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
DM dmitry
- Sep 21, 2006 04:46 PM UTC
- Sep 22, 2006 12:41 PM UTC