本文主要介绍如何在GridControl网格中的每一行增加复选框、下拉框和多选下拉框。最终效果如下图所示。
其中,测试模块,模块类型,从属,测试人,测试要求,备注等是数据库查询到的数据。
操作步骤:
一、添加控件
1. Winform窗口放置一个GridControl,默认有一个GridView
2. GridControl右上角选择Run Densigner,进入Grid Desginer
3. 添加需要加入网格的复选框(CheckEdit)、下拉框(LookUpEdit)和多选框(CheckedComboboxEdit)
4. 将GridView中的列与步骤3中添加的Repository关联起来,如下图所示
二、代码
1. Winform的Load事件中加入以下代码
private XXX_Load(object sender, EventArgs e)
{
this.gridView_ChildTaskList.OptionsBehavior.Editable = true;//可编辑
//this.gridView_ChildTaskList.Columns["task_id"].OptionsColumn.AllowEdit = false;
this.gridView_ChildTaskList.Columns["module_name"].OptionsColumn.AllowEdit = false;
this.gridView_ChildTaskList.Columns["module_type_name"].OptionsColumn.AllowEdit = false;//不可编辑
this.gridView_ChildTaskList.Columns["module_parent_name"