How to place a Readonly column?

Asked

Viewed 142 times

3

I’m trying to leave only one column of GridView as ReadOnly, I’m doing like this:

        if (id_crm == 0)
        {
            textBox2.Text = Convert.ToString(cod_crm());

            DataTable dat_itens = new DataTable();

            dat_itens.Columns.Add("ITEM", typeof(int));
            dat_itens.Columns.Add("DESCRIÇÃO", typeof(string));
            dat_itens.Columns.Add("DESCRIÇÃO NF", typeof(string));
            dat_itens.Columns.Add("QUANTIDADE", typeof(int));
            dat_itens.Columns.Add("OF ORIGEM", typeof(string));

            gridControl1.DataSource = dat_itens;

            gridView5.Columns[0].Width = 28;
            gridView5.Columns[0].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            gridView5.Columns["ITEM"].ReadOnly = true;  

        }

However, it displays an error:

inserir a descrição da imagem aqui

1 answer

2


The estate Gridcolumn.Readonly is read-only.

To specify whether a column is "editable" or you do not have to do so via property Gridcolumn.Optionscolumn thus:

gridView5.Columns["ITEM"].OptionsColumn.ReadOnly = true;
  • thank you very much. it worked perfectly, can you give me a brief explanation about what would be a read-only property? Thank you very much.

  • A read-only property cannot be changed, it is only possible to get its value. It is declared as follows public tipo Nome {get;}

  • I’m not sure, but I think that only applies to Devexpress Gridview’s.

  • @jbueno Yes, the question refers to Devexpress Gridview’s.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.