MaxDropDownItems of Datagridview Not Working?

Posted on 2009-07-03
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(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 & ""


        End With

    End Sub

Open in new window

Question by:koossa
  • 3

Expert Comment

by:Rahul Goel
Comment Utility

Author Comment

Comment Utility
I don't see the solution on the above link?

Accepted Solution

koossa earned 0 total points
Comment Utility
Uncheck the "Enable application framework" in the project properties.

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

Author Comment

Comment Utility
The last comment is a solution that I have posted, so I don't think you must delete.

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now