Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MaxDropDownItems of Datagridview Not Working?

Posted on 2009-07-03
6
Medium Priority
?
1,182 Views
Last Modified: 2012-05-07
Good day

My MaxDropDownItems of a DataGridViewComboBoxColumn is not working.

See my code blow?
Private Sub SetupPorsionsGrid()
        Dim colPorsionDescription As System.Windows.Forms.DataGridViewTextBoxColumn
        Dim colPorsionToSelect As System.Windows.Forms.DataGridViewComboBoxColumn
 
        colPorsionDescription = New System.Windows.Forms.DataGridViewTextBoxColumn
        colPorsionToSelect = New System.Windows.Forms.DataGridViewComboBoxColumn
 
        colPorsionDescription.ReadOnly = True
        colPorsionDescription.CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleRight
        colPorsionToSelect.CellTemplate.Style.Padding = New Padding(5, 11, 5, 11)
 
        colPorsionToSelect.Width = 120
        colPorsionToSelect.DropDownWidth = 80
        colPorsionToSelect.MaxDropDownItems = 3
        colPorsionToSelect.FlatStyle = FlatStyle.Flat
 
        lblSelectPorsionsCaption.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
 
        With grdPorsions
            .DefaultCellStyle.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            .BorderStyle = BorderStyle.Fixed3D
            .BackgroundColor = Color.OldLace
            .SelectionMode = DataGridViewSelectionMode.CellSelect
            .DefaultCellStyle.BackColor = Color.White
            .DefaultCellStyle.SelectionBackColor = Color.White
            .DefaultCellStyle.SelectionForeColor = Color.Black
            .MultiSelect = False
            .EditMode = DataGridViewEditMode.EditOnEnter
            .RowHeadersVisible = False
            .ColumnHeadersVisible = False
            .Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {colPorsionDescription, colPorsionToSelect})
            .ScrollBars = ScrollBars.None
 
            .Columns(0).Width = 272
            .Columns(1).Width = 120
            .AllowUserToAddRows = False
            .AllowUserToResizeColumns = False
            .AllowUserToResizeRows = False
            For iRowCount = 0 To 4
                .Rows.Add()
                .Rows(iRowCount).MinimumHeight = 47
            Next iRowCount
 
            .Rows(0).Cells(0).Value = "Item 1 : "
            .Rows(1).Cells(0).Value = "Item 2 : "
            .Rows(2).Cells(0).Value = "Item 3 : "
            .Rows(3).Cells(0).Value = "Item 4 : "
            .Rows(4).Cells(0).Value = "Item 5 : "
            Dim DropDownColumn As DataGridViewComboBoxColumn
            DropDownColumn = grdPorsions.Columns(1)
            For i = 0 To 200
                DropDownColumn.Items.Add(i & "")
                DropDownColumn.DisplayMember = i & ""
                DropDownColumn.ValueMember = i & ""
            Next
 
        End With
 
    End Sub

Open in new window

0
Comment
Question by:koossa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 

Author Comment

by:koossa
ID: 24771221
I don't see the solution on the above link?
0
 

Accepted Solution

by:
koossa earned 0 total points
ID: 24793450
Uncheck the "Enable application framework" in the project properties.

It seems like a visual style that's inherited from the operating system.
0
 

Author Comment

by:koossa
ID: 24981790
The last comment is a solution that I have posted, so I don't think you must delete.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question