Home Forums WinForms controls Other WinForms controls Binding winComboBox

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18436 |

    Ok, here we go. I am trying to bind a dataset to a form with several comboboxes. I am using the following code to bind to the winComboBox

    wcbL_PROPCLASS.DataBindings.Add(New Binding(“Text”, Globals.dsDD, “tblACT_LAND.CLASS”, True))

    The data in the dataset is a value of “R” and the combobox should display “RESIDENTIAL”

    I get no value at all. I have bound the data to a plain textbox and it does have the value.

    What am I doing wrong ?

    Imported from legacy forums. Posted by Ooh (had 2485 views)

    Xceed Support
    Member
    Post count: 5658

    I suggest that you directly use the DataSource and the DataMember properties instead.

    Here is a simple example:

    <code>
    private void Form1_Load( object sender, EventArgs e )
    {
    for( int j = 0; j < 4; j++ )
    {
    Column col = new Column( “Column” + j.ToString() );
    gridControl1.Columns.Add( col );
    }

    for( int i = 0; i < 20; i++ )
    {
    Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
    foreach( Cell cell in row.Cells )
    {
    cell.Value = “Item ” + i.ToString();
    }
    row.EndEdit();
    }

    DataSet ds = new DataSet();
    ds.Tables.Add( getDataTable() );

    WinComboBox wcb = new WinComboBox(EnhancedBorderStyle.None);
    wcb.DataSource = ds;
    wcb.DataMember = “MyTable”;

    gridControl1.Columns[ 0 ].CellEditorManager = new ComboBoxEditor( wcb );
    }

    private DataTable getDataTable()
    {
    //Create a DataTable
    DataTable dt = new DataTable();
    dt.TableName = “MyTable”;
    DataColumn dcId = new DataColumn();
    dcId.ColumnName = “Index”;
    dcId.DataType = System.Type.GetType( “System.Int64” );
    dt.Columns.Add( dcId );

    DataColumn dcName = new DataColumn();
    dcName.ColumnName = “Value”;
    dcName.DataType = System.Type.GetType( “System.String” );
    dt.Columns.Add( dcName );

    for( int i = 0; i < 50; i++ )
    {
    System.Data.DataRow row = dt.NewRow();
    row[ “Index” ] = i;
    row[ “Value” ] = i.ToString() + “%”;
    dt.Rows.Add( row );
    }

    return dt;
    }
    </code>

    Imported from legacy forums. Posted by CharlesB (had 4104 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.