Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to add dynamic row to data set

Status
Not open for further replies.

azarcomp

Programmer
Joined
Jul 9, 2010
Messages
11
Location
US
I was asked to add a row to a data set that is already in memory to be put into a combo box.

where and how do i put it in my code? It needs to say in combo box "Select Item"

'Location
Try
Dim colNames() As String = {"InventoryLocation", "InventoryLocationID", "Description"}
Dim dt As DataTable
dt = InvLocationAdapter.GetinvLocation
With MtgcboInvLoc
.Items.Clear()
.ColumnNum = 3
.ColumnWidth = "30;0;100"
.GridLineHorizontal = True
.GridLineVertical = True
.SourceDataString = colNames
.LoadingType = MTGCComboBox.CaricamentoCombo.DataTable
.SourceDataTable = dt
.SelectedIndex = 0
End With
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error" & " Get Inventory Locations")
End Try
 
Typically like this:
Code:
MyDataTable.Rows.Add(New Object(){1, "Value1"})

Where in this example, the DataTable has two columns--the first being an Integer I am setting to the number one, and the second being a string I am setting to "Value1
 
this way it will not let me specify which column i am putting it in


Try
Dim colNames() As String = {"InventoryLocation", "InventoryLocationID", "Description"}
Dim dt As DataTable
dt = InvLocationAdapter.GetinvLocation
dt.Rows.Add(New Object() {"Select", "0", ""})
With MtgcboInvLoc
.Items.Clear()
.ColumnNum = 3
.ColumnWidth = "30;0;100"
.GridLineHorizontal = True
.GridLineVertical = True
.SourceDataString = colNames
.LoadingType = MTGCComboBox.CaricamentoCombo.DataTable
.SourceDataTable = dt
.SelectedIndex = 0
End With
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error" & " Get Inventory Locations")
End Try
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top