DevExpress GridView in LookUpEdit

707 Views Asked by At

I can add columns like this in GridView, but I don't know how to add RepositoryLookUpEdit. Would you help me with this topic? (I'm sorry for my bad English.)

DataTable DT = new DataTable();

    private void Form1_Load(object sender, EventArgs e)
    {
        DT.Columns.Add("IP", Type.GetType("System.String"));
        DT.Columns.Add("Port", Type.GetType("System.String"));
        DT.Columns.Add("Username", Type.GetType("System.String"));
        DT.Columns.Add("Password", Type.GetType("System.String"));
        DT.Columns.Add("Working?", Type.GetType("System.Boolean"));
    }

    private void btn_ekle_Click(object sender, EventArgs e)
    {
        DataRow dr = DT.NewRow();
        dr[0] = "Test";
        dr[1] = "Test";
        dr[2] = "Test";
        dr[3] = "Test";
        dr[4] = true;
        DT.Rows.Add(dr);

        dtg_goster.DataSource = DT;
        gridView1.PopulateColumns();
1

There are 1 best solutions below

0
On

You can modify the RepositoryItemLookUpEdit's Columns property to add/remove columns. This can be done at runtime:

lookUpEdit1.Properties.Columns.Add(new LookUpColumnInfo("FieldName", "Caption", 100)); //100 is width in pixels

Similar to what you are doing with the GridControl, you can also use the LookUpEdit's PopulateColumns method to create a column for each field in the data source. Note that you may need to also invoke the LookUpEdit's ForceInitialize method before you invoke the PopulateColumns method to ensure that the control is fully initialized.