Pergunta

I have a GridControl on my windowsform. On a column, I want to show images+text conditionally.

On page load

    string command= "select cond, info from Table";
    SqlConnection conn = new SqlConnection("Data Source=10.10.10.10;Initial Catalog=zxcv;Persist Security Info=True;User ID=qw;Password=wq");
    conn.Open();
    SqlDataAdapter adap = new SqlDataAdapter(command, conn);
    DataTable dt = new DataTable();
    adap.Fill(dt);
    gridControl1.DataSource = dt;
    conn.Close();

How can I add images on the "cond" column conditionally(ex. if "cond" column is 1 i want to show 1.png+"Condition 1" on the cell).

Foi útil?

Solução

This is usually handled using a RepositoryItemImageComboBoxEdit. Create one of these and then edit the items so that each of your conditions is represented by one of the Items in the collection. Set your value to match the cond in your datasource and set an image to match the unique cond.

Then set the editor for your cond column to the RepositoryItemImageComboBoxEdit you created. And set the fieldName to the proper field "cond" to complete the binding.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top