CheckEdit as XtraGrid Column

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 = 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

Upvotes: 0

Views: 9996

Answers (3)

Caner SAYGIN
Caner SAYGIN

Reputation: 537

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.

Upvotes: 0

DevExpress Team
DevExpress Team

Reputation: 11376

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.

Upvotes: 1

Youp Bernoulli
Youp Bernoulli

Reputation: 5645

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.

Upvotes: 3

Related Questions