Hi,
Here is a real simple example. It loads the order details and
product tables from the northwind database. I display the order details in
the datagrid view. In the ProductID column I show a combobox with the
product name and price. I added a new column to my dataset which is an
expression of ProductName and Price columns added together. Hope this
helps.
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim strConn As String
Dim da, daProducts As SqlDataAdapter
Dim conn As SqlConnection
Dim ds As New DataSet
strConn = "Server = .;Database = NorthWind; Integrated Security =
SSPI;"
conn = New SqlConnection(strConn)
da = New SqlDataAdapter("Select * from [Order Details]", conn)
daProducts = New SqlDataAdapter("Select * from Products", conn)
da.Fill(ds, "Orders")
daProducts.Fill(ds, "Products")
DataGridView1.DataSource = ds.Tables("Orders")
DataGridView1.Columns.Remove("ProductID")
Dim dc As New DataColumn("MultiCols")
With dc
.Expression = "ProductName + ' ' + UnitPrice"
End With
ds.Tables("Products").Columns.Add(dc)
Dim dgvCombo As New DataGridViewComboBoxColumn
With dgvCombo
.Width = 150
.DataSource = ds.Tables("Products")
.DisplayMember = "MultiCols"
.ValueMember = "ProductID"
.DataPropertyName = "ProductID"
.HeaderText = "Product"
End With
DataGridView1.Columns.Add(dgvCombo)
End Sub
End Class
Ken
--------------------------
"Bob" <bd*****@sgiims.com> wrote in message
news:Os**************@TK2MSFTNGP11.phx.gbl...
Thinking two things,
1- Creating a userControl -yeah you guessed it, a multi column drop down
combobox - I've looked at several articles and did not find what I need,
one that's bindable and that I can use in a datagrid view.
2- Extending the datagridview so that it can be added to the list in the
column types when editing columns in the datagridview.
I'm really getting PO'd at Microsoft for not including a multi column
combobox both a the standard combox and as a datagridviewcombobox. Its
something so essential and they've been doing that in Access for years. We
had the capability in VB6, what the hell are we paying these overinflated
prices for development tools for?
Maybe I'm trying to reinvent the wheel?
Anyways, any ideas would be appreciated.
Bob