Hi all
I need to know weather it is possible to add a column to a datagrig that
based on a dataset, which is not in the dataset (like a description of a
code that appear in the datagrid).
here is the code I use to present data in the datagrid:
Code:
Private Sub FillDataGrid(ByRef dsDataSet As DataSet)
Try
Dim tsTableStyle As New DataGridTableStyle
tsTableStyle.MappingName = "myTable"
Dim clLineNo As New DataGridTextBoxColumn
With clLineNo
.MappingName = "line_no"
.HeaderText = "Line No"
.Width = 50
.NullText = ""
End With
tsTableStyle.GridColumnStyles.Add(clLineNo)
Dim clId As New DataGridTextBoxColumn
With clId
.MappingName = "id"
.HeaderText = "ID"
.Width = 80
.NullText = ""
End With
tsTableStyle.GridColumnStyles.Add(clId)
' Here I want a column that is not mapped to any field in the dataset, but a
descrition of the ID which I'll get by calling a function in my DB and here
the code I used with custom datagridtextboxcolumn: (between the asterix)
'***************************************************************************************************
Dim clDesc As New DataGridTextDescriptionColumn
With clDesc
'.MappingName = ""
'.TextBox.Text = clsDBORA.Get_Currency_Desc(strConnection,
clid.ToString)
.HeaderText = "Desc"
'.NullText = ""
End With
tsTableStyle.GridColumnStyles.Add(clDesc)
'****************************************************************************************************
Me.dgDataGrid.TableStyles.Clear()
Me.dgDataGrid.TableStyles.Add(tsTableStyle)
dgDataGrid.SetDataBinding(dsDataSet, "myTable")
Catch ex As Exception
HandleExceptions(ex)
End Try
End Sub
As a result of this, I wnat to see my grid like this:
Line No ID Description
1 S-10 descrition of ID S-10
2 S-20 descrition of ID S-20
and so on...
I tryed to use a custom datagridtextboxcolumn (here is the code)
Code:
Public Class DataGridTextDescriptionColumn
Inherits DataGridTextBoxColumn
Public Const strConnection = ("Provider=MSDAORA.1;Password=password;User
ID=user;Data Source=myDB")
Public clsDBORA As New clsDBORA
Public Sub New()
' Initialise the object and set its default properities
MyBase.New()
Me.NullText = ""
Me.ReadOnly = True
Me.TextBox.Text = clsDBORA.Get_Currency_Desc(strConnection, "USD")
End Sub
End Class
The result is that I don't see the new column at the grid.
If I open the remark from the mappingname property, and map this column to a
column in the dataset, I can see the new column, but the data I see is from
the mapped field, and not the one I made in my custom control.
Do you know what do I miss here?
Thanks
Thanks