R
Robert
Using VB.Net 2008
I have this code in a form, to create the cells on my datagridview.
Depending on the users selection, the grid is created.
This sample is for the Creditors.
Snipett:
The following works and populates the combo box, and the text boxes.
Need to find the ID value to enter it in the txtgrFixedID field once an
asset
is selected.
Try
With frmMain.grdSelections
..Columns.Clear()
'The commented code works to add a combo to the grid.
Dim txtgrFixedID As New DataGridViewTextBoxColumn
Dim colgrExpress As New DataGridViewComboBoxColumn
Dim txtgrMnthly As New DataGridViewTextBoxColumn
Dim txtgrYearly As New DataGridViewTextBoxColumn
txtgrFixedID.Name = "AssetsID"
With colgrExpress
'.Name = "Select a Variable Expense"
..HeaderText = "Select an Asset"
..ReadOnly = False
..AutoComplete = True
..DropDownWidth = 250
End With
With txtgrMnthly
..Name = "Value of Asset"
..DefaultCellStyle.NullValue = FormatNumber("0.00")
..ReadOnly = False
End With
With txtgrYearly
..Name = "Maturity Date"
..DefaultCellStyle.NullValue = Format(Now(), "MMM dd, yyyy")
..ReadOnly = True
End With
'Open the connection.
con.Open()
Dim rea As OleDbDataReader
Dim cmd As New OleDb.OleDbCommand("SELECT * FROM AssetsItems", con)
rea = cmd.ExecuteReader
colgrExpress.Items.Clear()
'Load the DataGridView.
While rea.Read()
colgrExpress.Items.Add(rea("NAssets"))
colgrExpress.DisplayMember = "NAssets"
colgrExpress.ValueMember = "AssetsID"
End While
'Close the connection.
con.Close()
..Columns.Add(txtgrFixedID)
..Columns.Add(colgrExpress)
..Columns.Add(txtgrMnthly)
..Columns.Add(txtgrYearly)
..Columns(0).Width = 0
..Columns(1).Width = 150
..Columns(2).Width = 100
etc.
I was able to use the ItemData in VB6.
I need to be able to fnd the AssetsID when user selects a value from the
combo box.
Any tips on how to get this.
Was so easy in VB6
I have this code in a form, to create the cells on my datagridview.
Depending on the users selection, the grid is created.
This sample is for the Creditors.
Snipett:
The following works and populates the combo box, and the text boxes.
Need to find the ID value to enter it in the txtgrFixedID field once an
asset
is selected.
Try
With frmMain.grdSelections
..Columns.Clear()
'The commented code works to add a combo to the grid.
Dim txtgrFixedID As New DataGridViewTextBoxColumn
Dim colgrExpress As New DataGridViewComboBoxColumn
Dim txtgrMnthly As New DataGridViewTextBoxColumn
Dim txtgrYearly As New DataGridViewTextBoxColumn
txtgrFixedID.Name = "AssetsID"
With colgrExpress
'.Name = "Select a Variable Expense"
..HeaderText = "Select an Asset"
..ReadOnly = False
..AutoComplete = True
..DropDownWidth = 250
End With
With txtgrMnthly
..Name = "Value of Asset"
..DefaultCellStyle.NullValue = FormatNumber("0.00")
..ReadOnly = False
End With
With txtgrYearly
..Name = "Maturity Date"
..DefaultCellStyle.NullValue = Format(Now(), "MMM dd, yyyy")
..ReadOnly = True
End With
'Open the connection.
con.Open()
Dim rea As OleDbDataReader
Dim cmd As New OleDb.OleDbCommand("SELECT * FROM AssetsItems", con)
rea = cmd.ExecuteReader
colgrExpress.Items.Clear()
'Load the DataGridView.
While rea.Read()
colgrExpress.Items.Add(rea("NAssets"))
colgrExpress.DisplayMember = "NAssets"
colgrExpress.ValueMember = "AssetsID"
End While
'Close the connection.
con.Close()
..Columns.Add(txtgrFixedID)
..Columns.Add(colgrExpress)
..Columns.Add(txtgrMnthly)
..Columns.Add(txtgrYearly)
..Columns(0).Width = 0
..Columns(1).Width = 150
..Columns(2).Width = 100
etc.
I was able to use the ItemData in VB6.
I need to be able to fnd the AssetsID when user selects a value from the
combo box.
Any tips on how to get this.
Was so easy in VB6