• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1113
  • Last Modified:

How to set the max number of entries to show in a drop down box

I have a datagridview that has a number of drop down boxes.  There are over 25 entries that show in the drop down box and the top value is blank.  Unfortunately the drop down box extends to the top of the screen and  is covering other information.  How can I set the max number of entries that will show at one time along with a scroll bar to see the rest of the items.  When I look at each column that is a combo box in the data grid, it has 8 set as the maximum drop down items, but that is not working.  I have also changed it to another number,but it still is not working.  Does anyone have any suggestions on how to solve this?
0
LenTompkins
Asked:
LenTompkins
  • 7
  • 3
  • 2
2 Solutions
 
dimajCommented:
Take a look at this link: http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.aspx

There is a property called MaxDropDownItems which is part of a ComboBox. This property should do what you are trying to achieve.
0
 
LenTompkinsAuthor Commented:
I tried that with this code as well as putting the max value in each column of the datagrid.

 //Set Binding for "PrefStartTime" Drop-down column
            this.PrefStartTme.DataPropertyName = "PrimaryStartChar";
            this.PrefStartTme.DataSource = this.m_dtStdCallingTime;
            this.PrefStartTme.DisplayMember = "CallingTimeChar";
            this.PrefStartTme.ValueMember = "CallingTimeChar";
            this.PrefStartTme.MaxDropDownItems = 10;
           
I still get all of the values
0
 
Todd GerbertIT ConsultantCommented:
Set IntegralHeight on your ComboBox to false, the MaxDropDownItems should take effect.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
LenTompkinsAuthor Commented:
Great, but I am a beginner and I can't see how we set the IntegralHeight or the DropDownHeight.  Can you give a code example?  
Thanks
0
 
LenTompkinsAuthor Commented:
I have tried :
this.cbxprefStart.IntegralHeight = false; which gives me an error setting the individual Combo box
this.gdvCallingTime.IntegralHeight = false;  gives me an error when setting the datagridview which holds
0
 
LenTompkinsAuthor Commented:
sorry I hit enter by mistake

but the dgv holds the combo boxes that I want to change.
0
 
dimajCommented:
correct, so you can change it at design time or at run time.
To change it at run time, you can use code you've listed above and just append the line I mentioned erlier.
To change it at design time, click on your dgv. You should see a little arrow in the upper right corner. When you click on it, you should be able to change properties for each column of your datagridview. Change properties you need and you won't have to mess with the code behind.

p.s. I assume you're working with Visual Studio.
0
 
LenTompkinsAuthor Commented:
//Set Binding for "PrefStartTime" Drop-down column
            this.PrefStartTme.DataPropertyName = "PrimaryStartChar";
            this.PrefStartTme.DataSource = this.m_dtStdCallingTime;
            this.PrefStartTme.DisplayMember = "CallingTimeChar";
            this.PrefStartTme.ValueMember = "CallingTimeChar";
            this.PrefStartTme.IntegralHeight = false;
            this.PrefStartTme.MaxDropDownItems = 9;

I get the following error:
'System.Windows.Forms.DataGridViewComboBoxColumn' does not contain a definition for 'IntegralHeight' and no extension method 'IntegralHeight' accepting a first argument of type 'System.Windows.Forms.DataGridViewComboBoxColumn' could be found (are you missing a using directive or an assembly reference?)

I even tried it earlier in when I load the form and I get the same error.  Is there a different using statement that I need?
0
 
Todd GerbertIT ConsultantCommented:
IntegralHeight is for the drop-down/combo-box, not the grid view.
0
 
LenTompkinsAuthor Commented:
this.PrefStartTme is my combo box within my grid and I tried to set the IntegralHeight on this element.  Is this not the correct element to set it to?
0
 
LenTompkinsAuthor Commented:
I needed to upgrade the platform I am using to make this work.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 7
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now