开发者

CheckEdit as XtraGrid Column

开发者 https://www.devze.com 2023-03-14 02:05 出处:网络
edit = gridView1.GridControl.RepositoryItems.Add(\"CheckEdit\") as RepositoryItemCheckEdit; column = gridView1.Columns.Add();
edit = gridView1.GridControl.RepositoryItems.Add("CheckEdit") as RepositoryItemCheckEdit;
column = gridView1.Columns.Add();
column.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
column.VisibleIndex = 0;
column.FieldName = "CheckMarkSelection";
column.Caption = "Mark";
column.OptionsColumn.ShowCaption = false;
column.UnboundType = 开发者_Go百科DevExpress.Data.UnboundColumnType.Boolean;
edit.NullStyle = StyleIndeterminate.Unchecked;
column.ColumnEdit = edit;

I suppose I succeed in adding a checkedit column into gridview but i still can't check multiple rows and can't access edit's check state. Why? i ll be appreciated, because i have been struggling with this for 3 days


Use the designer of the gridview. Goto columns, select the column you would like to be a checkedit. Go to ColumnEdit and select a checkedit. Then you really should be able to check multiple rows for this editor. Multiselect (selecting multiple rows simultaneously) is in the OptionsBehavior I guess. When I'm at work (tomorrow) I can provide you with a sample. It can't be very difficult that's for sure.


The problem appears because the column is marked as unbound. In this case, the GridView generates the CustomUnboundColumnData event which can be used to provide data to this column and save it. I think you should handle this event to resolve the original problem.


In the GridDesigner, for CheckEdit, set "NullStyle" property to "Unchecked", and for the column that you are going to use for CheckEdit, set "FieldName" property to the name of your column in the datatable (I used "col1" for boolean values true,false). After you set everything at the GridDesigner, you have to declare a type for the columns. For example i used a code like this;

public DataTable datas = new DataTable();

private void Form1_Load(object sender, EventArgs e)
    {
        datas.Columns.Add("col1", typeof(bool));
        datas.Columns.Add("col2", typeof(string));
        datas.Columns.Add("col3");
        gridControl.DataSource = datas;
    }

datas.Rows.Add(False, "someValue", "");
datas.Rows.Add(False, "someValue", "");
datas.Rows.Add(True, "someValue", "");
datas.Rows.Add(False, "someValue", "");

Than it should work. I hope it is the solution of your problem. Thanks.

0

精彩评论

暂无评论...
验证码 换一张
取 消