PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2008 I'm having trouble entering data into my datagridviewer combobox column-VBForums
Results 1 to 4 of 4

Thread: I'm having trouble entering data into my datagridviewer combobox column

  1. #1

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Question I'm having trouble entering data into my datagridviewer combobox column

    I have this test form where I'm testing the idea, but ran into a snag.

    Name:  uuuuu.JPG
Views: 95
Size:  11.9 KB

    Now the main idea is to load all the data from a dataset into the one column of the datagridview. This works perfectly as shown in the image.

    Now there is something that I want to happen, but just can't get it right.

    when on the DataGridViewComboBox Column I also want to be able to type in my own data if the one I want is not available in the combobox.

    Also if there are 50 values in my combobox and 2 of them are:

    jacky, jacson

    When i type jac
    I want the combobox to only give me the options starting with "jac"

    Here is the code that I'm currently using:

    3 Code:
    1. Dim dt As DataTable
    2.     Dim dsNewDataset As New DataSet()
    3.     Dim i = 0, intSetArray As Integer = 0
    4.  
    5. Public Function JT_PullDataWithCOLUMNS1(ByVal Cols As String, ByVal TableName As String) As DataTable
    6.         If dsNewDataset.Tables.Count >= 1 Then
    7.             dsNewDataset.Clear()
    8.             intSetArray = 0
    9.             i = 0
    10.         End If
    11.         Dim conn As String = "Server=192.132.0.53;Port=3306;Database=wic;Uid=root;Pwd=12sw"
    12.         Dim cmd As String = "SELECT " & Cols & " FROM " & TableName
    13.         Dim ad As New MySql.Data.MySqlClient.MySqlDataAdapter(cmd, conn)
    14.  
    15.         ad.GetFillParameters()
    16.         ad.Fill(dsNewDataset)
    17.  
    18.         dt = dsNewDataset.Tables(0)
    19.  
    20.         JT_PullDataWithCOLUMNS1 = dsNewDataset.Tables(0)
    21. End Function
    22.  
    23.  
    24.  
    25. Private Sub InsertUserList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    26.         Dim aa As DataSet = JT_PassDataSet
    27.         'DGV.DataSource =
    28.         Call JT_PullDataWithCOLUMNS1("PASSWORD", "st_users")
    29.  
    30.         Dim comboboxcol As DataGridViewComboBoxColumn = Me.DGV.Columns("PASSWORD")
    31.         comboboxcol.DataSource = dt
    32.         comboboxcol.DisplayMember = "PASSWORD"
    33.         comboboxcol.ValueMember = "PASSWORD"
    34.         comboboxcol.ReadOnly = False
    35. End Sub

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,877

    Re: I'm having trouble entering data into my datagridviewer combobox column

    The DataGridViewComboBoxColumn is not designed to work that way. You would have to create your own custom column.

  3. #3

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Re: I'm having trouble entering data into my datagridviewer combobox column

    Ok. I'm new to programming, can you perhaps give me a example by code?

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,877

    Re: I'm having trouble entering data into my datagridviewer combobox column

    It's a far from trivial exercise. You first need to understand the relationship between the column, cell and editing control classes. You then need to derive your own classes from the appropriate base classes, i.e. DataGridViewComboBoxColumn and DataGridViewComboBoxCell. If you're not comfortable with that then you've got a lot of reading and playing with code ahead of you. I'd suggest that you start by reading about the DataGridView and how it works on MSDN.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width