Controls

Combobox

Fill with item and value

cboLayout.DataSource = datatable 'Can be filled manually (see databases)
cboLayout.DisplayMember = "Description"
cboLayout.ValueMember = "Key"
Result = cboLayout.SelectedValue

Fill with objects

Loading:
For Each mTable As Table In mDatabase.mTables
  cboTable.Items.Add(mTable)
Next
cboTable.DisplayMember = "naam"
Reading:
mTable = CType(cboTable.SelectedItem, Table)
Fill text (uses .ToString() method of object):
Public Class Table
  Public name As String
  Public schema As String
  Public Overrides Function ToString() As String
    Return String.Format("{0}.{1}", schema, name)
  End Function
End Class

Datagridview

Common methods

Use SelectionChanged instead of CellClick, unless you really only want to react on clicking.
Mind that SelectionChanged gets EventArgs instead of DataGridViewCellEventArgs.
EventArgs don't have a RowIndex. Replace it with dgv.CurrentRow.Index.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License