Click here to Skip to main content
15,878,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Dear Pros,

i'm looking for an Solution to hide DrowDown Entrys, so i can select Values with my code to fill the combobox with and the User can only use limited values.

VB
Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) _
Handles Button1.Click
    Dim source As New DataTable()
    source.Columns.Add("desc")
    source.Columns.Add(New DataColumn("value", GetType(Integer)))

    Dim row As DataRow = source.NewRow
    row("desc") = "for User to use"
    row("value") = 1
    source.Rows.Add(New Object() {"for User to use", 2})
    source.Rows.Add(New Object() {"Not for User to use 1", 4})
    source.Rows.Add(New Object() {"Not for User to use 2", 6})



    Dim combocol As New DataGridViewComboBoxColumn()
    With combocol
        .Name = "combo"
        .DataSource = source
        .ValueMember = "value"
        .DisplayMember = "desc"
        'i am looking for something like:
        '##############################
        '.HideEntry(1) 'Index
        'or
        '.HideEntry(4) 'Value
        'or
        '.HideEntry("Not for User to use 1") 'Text

        'so the User can only select 'for User to use'
    End With
    DataGridView1.Columns.Add(combocol)

    Dim Content As New DataTable()
    With Content
        .Columns.Add("col1")
        .Columns.Add("col2")
        .Rows.Add(New String() {"hallo", "hans"})
        .Rows.Add(New String() {"wie", "gehts"})
    End With
    DataGridView1.DataSource = Content

    'This should make to code but shoud be dissabled for the user use
    DataGridView1.Rows(2).Cells("combo").Value = 4

End Sub


Thank you for your effords
Best Regards
Florian Reiter
Posted
Updated 10-Mar-14 23:02pm
v2

1 solution

Use this line above of DataGridView1.Columns.Add(combocol)

VB
''''''' This can be remove the row
       source.Rows(1).Delete()


VB
'DataGridView1.Rows(2).Cells("combo").Value = 4
       Me.DataGridView1.Rows(1).Cells(0).ReadOnly = True
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900