Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Trouble with combobox in DataGrid

Trouble with combobox in DataGrid

Scheduled Pinned Locked Moved Visual Basic
cssdatabasegraphicshelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fiaolle
    wrote on last edited by
    #1

    Hi The first set of source code is the class for a combobox in a grid, hopefully. In the second set of code we try to use the combobox class, but the grid is empty. I don't understand how this works. The first set of code I downloaded from internet and when i tried it, it worked fine. But when I changed the second part of the code it started to give me trouble. Before I changed the code they used Datacolumns,Datarows and Datatables and added them to the Dataset which they used to the Datagrid and it worked fine. I don't understand what is wrong know that I'm using a table I haven't "made" myself but a table I got from a connection. As the third set of code showing, when using comboboxes you can set the Datasource to a table you have connected to with a connection and it works fine, so I think the second part of code should work, but the grid is empty when the program starts. If there is anyone who understand my problem and have a solution, please give me an answer. Thanks Fia 'The MyComboColumn class Imports System.Data Imports System.Drawing Imports System.Collections Imports System.Windows.Forms Namespace ComboBoxTest Public Class MyComboColumn Inherits System.Windows.Forms.DataGridTextBoxColumn Private _cboColumn As ComboBox Private _objSource As Object Private _strMember As String Private _strValue As String Private _bIsComboBound As Boolean = False Private _backBrush As Brush = Nothing Private _foreBrush As Brush = Nothing Private _iRowNum As Integer Private _cmSource As CurrencyManager Public Sub New(ByVal objSource As DataSet, ByVal strMember As String, ByVal strValue As String, ByVal bUseDropDownList As Boolean) '_objSource = objSource _strMember = strMember _strValue = strValue _cboColumn = New ComboBox _cboColumn.DataSource = objSource.Tables(0) _cboColumn.DisplayMember = _strMember _cboColumn.ValueMember = _strValue If bUseDropDownList = True Then _cboColumn.DropDownStyle = ComboBoxStyle.DropDownList Me.ReadOnly = True Else 'AddHandler _cboColumn.KeyPress, AddressOf _cboColumn_KeyPress AddHandler _cboColumn.KeyUp, AddressOf _cboColumn_KeyUp End If AddHandler _cboColumn.Leave, AddressOf cboColumn_Leave _cboColumn.Visible = False End Sub Private Sub _cboColumn_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) e.Handled = True End Sub Private Shadows Sub _cboColumn_KeyUp(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) Dim index As Integer Dim actual As String Dim found As String ' Do nothing for cer

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups