private BindingDescriptor<EditableColumn> createUserBindingDescriptor() { BindingDescriptor<EditableColumn> bd = new BindingDescriptor<EditableColumn>(); EditableColumn column = new EditableColumn(); column.DataType = typeof(string); column.Name = "Username"; column.ObjectPropertyName = column.Name; column.Editable = true; column.Widget = typeof(TextBox); column.Visible = true; EditableColumn column2 = new EditableColumn(); column2.DataType = typeof(string); column2.Name = "Email"; column2.ObjectPropertyName = column2.Name; column2.Editable = true; column2.Widget = typeof(TextBox); column2.Visible = true; EditableColumn column3 = new EditableColumn(); column3.DataType = typeof(int); column3.Name = "Desk"; column3.ObjectPropertyName = column3.Name; column3.Editable = true; column3.Widget = typeof(IntegerTextBox); column3.Visible = true; EditableColumn column4 = new EditableColumn(); column4.DataType = typeof(bool); column4.Name = "Is Active"; column4.ObjectPropertyName = "IsActive"; column4.Editable = true; column4.Widget = typeof(CheckBox); column4.Visible = true; bd.BindingColumns.Add(column); bd.BindingColumns.Add(column2); bd.BindingColumns.Add(column3); bd.BindingColumns.Add(column4); return bd; }
private void createBindingDescriptorFromTable() { BindingDescriptor = new BindingDescriptor<EditableColumn>(); foreach (DataColumn dColumn in _dataTable.Columns) { Logger.GetInstance().WriteLine("dataTableGrid reading column:" + dColumn.ColumnName); EditableColumn editColumn = new EditableColumn(); editColumn.Editable = true; editColumn.DataType = dColumn.DataType; editColumn.Name = dColumn.ColumnName; editColumn.ObjectPropertyName = dColumn.ColumnName; editColumn.Visible = true; if (typeof(int).IsAssignableFrom(dColumn.DataType)) { editColumn.Widget = typeof(IntegerTextBox); } else if (typeof(bool).IsAssignableFrom(dColumn.DataType)) { editColumn.Widget = typeof(CheckBox); } else { editColumn.Widget = typeof(TextBox); } BindingDescriptor.BindingColumns.Add(editColumn); } }