Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Creating Automated Adjustable ComboBox Using C#

Author: DevASP
Download Source Code : 540_AutomaticDropDownWidth.zip

In This Article I Will Explain You The Way In Which You Can Create Automatic Adjustable Combo Box. Source code Is Given with this article.

In this Article I will Shows how to implement a combo box which adjusts the width of the drop down list when showing it. Write this Region in your code. It adjust the combo box by programmer defined Properties.

 

#region Vom Windows Form-Designer generierter Code

            private void InitializeComponent()

            {

                  this.comboBox1 = new System.Windows.Forms.ComboBox();

                  this.SuspendLayout();

                  //

                  // comboBox1

                  //

                  this.comboBox1.BackColor = System.Drawing.SystemColors.Highlight;

                  this.comboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;

                  this.comboBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.comboBox1.ForeColor = System.Drawing.SystemColors.HighlightText;

                  this.comboBox1.Items.AddRange(new object[] {

                                                                                       "a",

                                                                                       "aa",

                                                                                       "aaa",

                                                                                       "aaaa",

                                                                                       "aaaaa",

                                                                                       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +

                                                                                       "aaaaa"});

                  this.comboBox1.Location = new System.Drawing.Point(56, 64);

                  this.comboBox1.Name = "comboBox1";

                  this.comboBox1.Size = new System.Drawing.Size(144, 27);

                  this.comboBox1.TabIndex = 0;

                  this.comboBox1.Text = "comboBox1";

                  this.comboBox1.Visible = false;

                  //

                  // Form1

                  //

                  this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

                  this.ClientSize = new System.Drawing.Size(292, 266);

                  this.Controls.Add(this.comboBox1);

                  this.Name = "Form1";

                  this.Text = "DevAsp";

                  this.Load += new System.EventHandler(this.Form1_Load);

                  this.ResumeLayout(false);

 

            }

            #endregion

In This region Also Assign The values To code,Adjust the Client size According to values assigns. Source code is given with this article .And theses Functions Are Given in attached application. It is recommended run application first. In this Article I tried to explain that how to implement a combo box which adjusts the width of the drop down list According to the Assign values.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Structured Programming in C#

Disclaimer - Privacy
© 2002-2017 DevASP.net