How to set column ticked from other column

chopperfield

How can I set a value into gridview column? The thing is the column was added manually, not from the database. What I want is when the checklist value was 1 the cek22 column got ticked and when value was 0 the cek22 column was unticked. I used devexpress.

Example of my code that I used:

public void abc()
{
    //select query in here
    gridControl1.DataSource = dt;

    //iam adding a column here
    dt.Columns.Add("cek22",typeof(bool));
}

enter image description here

nempoBu4

If your column is added manually then your column is working in unbound mode. So, you can just use its unbound expression. If you want to update your checklist column from cel22 then you can use CellValueChanging event.
Here is example:

var table = new DataTable();

table.Columns.AddRange(new[]
{
    new DataColumn("preferred", typeof(string)),
    new DataColumn("checklist", typeof(int))
});

table.Rows.Add("Director Fury", 1);
table.Rows.Add("Maria Hill", 0);

gridControl1.DataSource = table;
gridView1.PopulateColumns();

var column = new GridColumn();
column.FieldName = "cek22";
column.UnboundType = UnboundColumnType.Boolean;
column.UnboundExpression = "[checklist]";
column.Visible = true;

gridView1.Columns.Add(column);

gridView1.CellValueChanging += (sender, e) =>
{
    if (e.Column.FieldName == "cek22")
        gridView1.SetRowCellValue(e.RowHandle, "checklist", e.Value);
};

Here is the result: Result

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to use column from other table in Laravel

Set values of column based on other column

how to get desired column from other table

How to use .loc to set as other column values in pandas

How to add new column and get the data from other column? SQL

SQL. Set column Value from a choice of other columns

How to set values of a column based on multiple conditions in other columns in python?

Set column values based on lookup from other column

How to recreate new columns with column names from one column & column values from the other

How to fill a column to differentiate a set of rows from other rows in a group in Impala?

How to create index column for set of values in other column

How to fill a column automatically from special values in other column?

How to exclude a set of numbers from a master column

How to set variable value from column data?

How to select from one column or the other?

How to replace a string in a column with other string from the same column

How to remove a row/column from a result set?

How to Copy Data From Other Column Based On Other Cloumn Values

How to set nan iteratively in column based on other column value?

How to use UPDATE SET without making other column values NULL

How to extract values from column based on string value in other column?

How to set multiindex column from existing multiindex column df

how to set value on one of column on excel from other sheet column on excel

how to extract all first value in a column from other column

pandas: cannot set column with substring extracted from other column

How to set column name from column value in Pandas Python?

How to set a column by slicing values of other columns

How to add a column which does a string addition of values from other column based on condition from another column

How to set new values to row based on the same substring from other column?