cancel
Showing results for 
Search instead for 
Did you mean: 

Load a SAP table in a datagrid,How can I hide a column??

Former Member
0 Kudos

Hi,Dear All

SAP table not like system.data.Datatable.

So,how can I hide a column(s)

(convert saptable to System.Data.DataTable ??)

Thanks in advance

Yi

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I resolved it by myself

Dim ts As New DataGridTableStyle

Me.SapProxy11.Get_Cpu_Single("LOCAL", " ", 0, 0, 0, 0, "", 0, 0, "", 0, dstcpu)

'dst.AllowNew = False

'dst.alll = False

' DataGrid1.DataSource = dstcpu

ts.MappingName = "dstcpu"

dt = dstcpu.ToADODataTable()

'dt = DBSet.Tables(0)

Dim aColumnTextColumn As DataGridTextBoxColumn

DataGrid1.DataSource = dt

ts.MappingName = dt.TableName

Dim numCols As Integer

numCols = dt.Columns.Count

Dim i As Integer = 0

Do While (i < numCols)

aColumnTextColumn = New DataGridTextBoxColumn

aColumnTextColumn.HeaderText = dt.Columns(i).ColumnName

aColumnTextColumn.MappingName = dt.Columns(i).ColumnName

ts.PreferredColumnWidth = 100

ts.PreferredRowHeight = 20

If i = 0 Or i = 1 Or i = 2 Then

aColumnTextColumn.Width = 0

End If

ts.AlternatingBackColor = Color.LightGray

ts.GridColumnStyles.Add(aColumnTextColumn)

i = (i + 1)

Loop

Hope it can give helps to others

Yi

reiner_hille-doering
Active Contributor
0 Kudos

This is not an ideal solution.

Use DataGridTableStyle and DataGridColumnStyle directly with the SAP-Table (not ADO-Table). Set DataGridTableStyle's "MappingName" property to the name of the type of the SAP Table, e.g. "BRFCKNA1Table".

This features all nicely work directly in VS IDE, e.g. if you create an instance of the SAP Table on the designer with the "SAP Table Wizard" or if you use proxy fields. Please see the Tutorias for details.

Former Member
0 Kudos

I can not use DataGridTableStyle to make datagrid

so anybody has any ideas on this one????

Yi