I have DataGrid
that some columns are CheckBox
, I'm using the RepositoryItemCheckEdit
method of DevExpress to do this:
However, how do I make a Check
? I know I need to use the gridView1.SetRowCellValue
property, but even setting the value to true
CheckBox
of column remains Uncheck
I have the same problem as this link: RepositoryItemCheckEdit does not stay checked but even so I could not solve it.
Code of RepositoryItemCheckEdit
private void check_column()
{
DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit acessar_select = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
gridView1.Columns["ACESSAR"].ColumnEdit = acessar_select;
acessar_select.ValueChecked = true;
acessar_select.ValueUnchecked = false;
acessar_select.AllowGrayed = false;
acessar_select.CheckStyle = CheckStyles.Standard;
acessar_select.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked;
DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit inserir_select = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
gridView1.Columns["INSERIR"].ColumnEdit = inserir_select;
inserir_select.ValueChecked = true;
inserir_select.ValueUnchecked = false;
inserir_select.AllowGrayed = false;
inserir_select.CheckStyle = CheckStyles.Standard;
inserir_select.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked;
DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit editar_select = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
gridView1.Columns["EDITAR"].ColumnEdit = editar_select;
editar_select.ValueChecked = true;
editar_select.ValueUnchecked = false;
editar_select.AllowGrayed = false;
editar_select.CheckStyle = CheckStyles.Standard;
editar_select.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked;
DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit excluir_select = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
gridView1.Columns["EXCLUIR"].ColumnEdit = excluir_select;
excluir_select.ValueChecked = true;
excluir_select.ValueUnchecked = false;
excluir_select.AllowGrayed = false;
excluir_select.CheckStyle = CheckStyles.Standard;
excluir_select.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked;
DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit imprimir_select = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
gridView1.Columns["IMPRIMIR"].ColumnEdit = imprimir_select;
imprimir_select.ValueChecked = true;
imprimir_select.ValueUnchecked = false;
imprimir_select.AllowGrayed = false;
imprimir_select.CheckStyle = CheckStyles.Standard;
imprimir_select.NullStyle = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked;
}
Code that fills in the data (query the bank):
private void preenche_form(string iduser)
{
Classes.Datatable.Datatable_permissoes dat_permis = new Classes.Datatable.Datatable_permissoes();
DataTable retorno = dat_permis.preenche_permis(iduser);
DataTableReader dtr = retorno.CreateDataReader();
if (dtr.HasRows)
{
while (dtr.Read())
{
string tela = dtr["roleid"].ToString();
string[] Linha = tela.Split('.');
string expression = ("id = " + "'" + Linha[0] + "'").ToString();
DataRow[] index = ret_permi.Select(expression);
int t = ret_permi.Rows.IndexOf(index[0]);
if(Linha[1] == "1")
{
gridView1.SetRowCellValue(t, gridView1.Columns["ACESSAR"], true);
}
else if (Linha[1] == "2")
{
gridView1.SetRowCellValue(t, gridView1.Columns["INSERIR"], true);
}
else if (Linha[1] == "3")
{
gridView1.SetRowCellValue(t, gridView1.Columns["EDITAR"], true);
}
else if (Linha[1] == "4")
{
gridView1.SetRowCellValue(t, gridView1.Columns["EXCLUIR"], true);
}
else if (Linha[1] == "5")
{
gridView1.SetRowCellValue(t, gridView1.Columns["IMPRIMIR"], true);
}
}
}
Screen:
EDITIONS
Afterresearchingontheinternet,IwasabletodoCheck
,butwhenIclickedonacell,itCheck
inalloftheline: