Search code examples
c#datatablebusiness-objects

How to set Grid.DataTable column values to not editable using C# in SAP


I created a simple DataTable in SAP using C# and fill the table with a Query. Afterwards I can display the table without any problem. But the user can edit column values which is not nice. I can't find a way to make them not editable.

Is there a simple way do this like oGrid.Datatable.Columns.readonly()...?

I know in C# "DataGridView" you can do that.

Any SAP pros who can help me? Thanks in advance!

My code can be seen below

            private SAPbouiCOM.Grid oGrid;
            ....
            //  Set the grid data
            oGrid = ((SAPbouiCOM.Grid)(oItem.Specific));

            oForm.DataSources.DataTables.Add("MyDataTable");
            oForm.DataSources.DataTables.Item(0).ExecuteQuery("....");
            oGrid.DataTable = oForm.DataSources.DataTables.Item("MyDataTable");
            GridCount = oGrid.DataTable.Rows.Count;
            //  Set columns size
            oGrid.Columns.Item(0).Width = 50;
            oGrid.Columns.Item(1).Width = 60;
            oGrid.Columns.Item(2).Width = 130;

Solution

  • It was found out to be a very easy thing to do. But there's no way to just set the whole table to not editable. You have set each and every column to not editable like below.

    oGrid.Columns.Item(0).Editable = false;