Last Updated: February 25, 2016
·
374
· vitochung

set grid column from option

CommObjects.SetOptionGridColumn

public static void SetOptionGridColumn(GridControl grid, GridColumn col, int optIdx)
{
    string sql = "SELECT item_no, name FROM app_table_field_option_item WHERE opt_no = {0} ORDER BY item_no ";
    DataTable dt = AppFuncs.GetTableBy("app_table_field_option_item", string.Format(sql, optIdx));
    RepositoryItemLookUpEdit rc = new RepositoryItemLookUpEdit();
    rc.DataSource = new BindingSource(dt, null);
    rc.DisplayMember = "name";
    rc.ValueMember = "item_no";
    rc.PopulateColumns();
    rc.Columns[0].Visible = false;
    rc.ShowHeader = false;
    rc.ShowFooter = false;
    rc.AutoSearchColumnIndex = 0;
    grid.RepositoryItems.Add(rc);
    col.ColumnEdit = rc;
}