我需要在 Syncfusion Windows 窗体网格中创建一个带有复选框的列。我可以创建一个只有一个复选框的列,但无法在其旁边添加文本。谁能帮我这个?我在 Syncfusion 论坛上找不到任何资料。
最佳答案
这是从 Syncfusion 的在线文档中摘录的代码示例——WinForms 网格用户指南的第 4.1.4.1.1 节,在“向网格单元添加特殊控件”下。
Description 属性添加出现在复选框旁边的文本。
[C#]
// Specify display values for True/False/Indeterminate.
gridControl1.TableStyle.CheckBoxOptions = new GridCheckBoxCellInfo("True", "False", "", false);
// Set up a check box with no tristate.
gridControl1[rowIndex,colIndex].CellValue = false;
gridControl1[rowIndex,colIndex].Description = "Click Me";
gridControl1[rowIndex,colIndex].CellType = "CheckBox";
gridControl1[rowIndex,colIndex].TriState = false;
// Set up a check box with tristate.
gridControl1[rowIndex,colIndex + 1].CellValue = true;
gridControl1[rowIndex,colIndex + 1].CellType = "CheckBox";
gridControl1[rowIndex,colIndex + 1].TriState = true;
gridControl1[rowIndex,colIndex + 1].Description = "TriState";
[VB.NET]
' Specify display values for True/False/Indeterminate.
gridControl1.TableStyle.CheckBoxOptions = New GridCheckBoxCellInfo("True", "False", "", False)
' Set up a check box with no tristate.
gridControl1(rowIndex, colIndex).CellValue = False
gridControl1(rowIndex, colIndex).Description = "Click Me"
gridControl1(rowIndex, colIndex).CellType = "CheckBox"
gridControl1(rowIndex, colIndex).TriState = False
' Set up a check box with tristate.
gridControl1(rowIndex, colIndex + 1).CellValue = True
gridControl1(rowIndex, colIndex + 1).CellType = "CheckBox"
gridControl1(rowIndex, colIndex + 1).TriState = True
gridControl1(rowIndex, colIndex + 1).Description = "TriState"
关于windows - Syncfusion Windows 窗体网格 - C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5803398/