Accessing cell properties from DataGrid object

Hi,

I have a datagrid object and I want to access the properties of a cell in a datagird at a given row and column. How can I do this

Thanks,



Answer this question

Accessing cell properties from DataGrid object

  • dmcrews4202

    Do you use DataGrid or DataGridView I suggest you use DataGridView and it can disable cells by "grid[col, row].ReadOnly" property.

  • dr.xaml

    Hi,there is a FAQ about How do I disable a cell I hope it is what you want.

  • wgreer

    It worked in the cellbegin edit event.....

  • Gabriel Petrovay

    If you want just to disable some of the cell of a .Net 1.1 DataGrid, see this sample.

  • harryv

    I am still using .NEt 1.1 .I cant use 2.0 yet.
  • Andy Roberts - MSFT

    HI,

        I'm looking for the same functionality. I need to disable a particular cell(datagridveiw). In which event i need to make the cell as readonly.

     

    venp--



  • quoi

    ACtually I was trying to disable the cell for editing.
  • npvw

    That's sad. Still you can change AllowEdit to false in DataView when you enter protected cell and change it back to true when you enter another cell (you can do this in CurrentCellChanged event handler).

  • n9986

    In DataGridView you can access cells by grid[col,row].

    In DataGrid there is no cell properties.



  • Chrisjwood

    Hi,bilalso

    For DataGrid in NET 1.1, there's no direct property to access a certain cell, but if you want to disable a whole column, you can use the DataGridTableStyle, e.g.:

    this.dataGrid1.DataSource = dtBook;//a datatable named "dtBook"

    DataGridTableStyle tbStyle = new DataGridTableStyle();

    tbStyle.MappingName = "dtBook";

    this.dataGrid1.TableStyles.Add(tbStyle);

    this.dataGrid1.TableStyles["dtBook"].GridColumnStyles[2].ReadOnly = true;//disable the 3rd column

    Hope it helps.
    Best Regards.
    Ye



  • Accessing cell properties from DataGrid object