cancel
Showing results for 
Search instead for 
Did you mean: 

How to bind Column of grid?

0 Kudos

I am getting Error "Unable to cast COM object of type 'System.__ComObject' to interface type 'SAPbouiCOM.Columns'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C830390A-4D84-4DA6-8D9A-91322F9A37EC}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))." while binging Grid column . Here is my code

Public Sub BindGrid()

Dim objgrid As SAPbouiCOM.Grid

Try

Dim oColumns As SAPbouiCOM.Columns

Dim oColumn As SAPbouiCOM.Column

oForm = objMain.objApplication.Forms.ActiveForm

objgrid = oForm.Items.Item("11").Specific

oColumns = objgrid.Columns

oColumn = oColumns.Item("ItemCode")

oColumn.DataBind.SetBound(True, "WTQ1", "ItemCode")

oColumn = oColumns.Item("Item Name")

oColumn.DataBind.SetBound(True, "WTQ1", "Dscription")

oColumn = oColumns.Item("Qty")

oColumn.DataBind.SetBound(True, "WTQ1", "Quantity")

oColumn = oColumns.Item("From Whs")

oColumn.DataBind.SetBound(True, "WTQ1", "FromWhsCod")

oColumn = oColumns.Item("ToWH")

oColumn.DataBind.SetBound(True, "WTQ1", "WhsCode")

Catch ex As Exception

MessageBox.Show(ex.Message)

objMain.LogError(ex)

End Try

End Sub

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member390407
Contributor
0 Kudos

Hi Megha,

You work with grid as with matrix. The Grid interface doesn't have property of type "Columns" it has "GridColumns" instead (same with "Column"). If you want to bind the data source to a grid you can use the DataTable property. Example from the SDK help:

Set oDataTable = oForm.DataSources.DataTables.Item(m_DataTableUid)
queryStr = "Select 0, CardName, CardType, GroupNum from OCRD"
oDataTable.ExecuteQuery queryStr