We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Combobox Autocomplete

When I create a autocomplete combobox dynamically then it does not shown any dropdown item. Even afte assigning a datasource.

#region Copyright Syncfusion Inc. 2001 - 2007
//
// Copyright Syncfusion Inc. 2001 - 2007. All rights reserved.
//
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// licensing@syncfusion.com. Any infringement will be prosecuted under
// applicable laws.
//
#endregion

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Syncfusion.Windows.Forms.Tools;
using Syncfusion.Windows.Forms;

namespace ComboBoxAutoCompleteDemo
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
private ArrayList itemsList = new ArrayList();
private ArrayList alphaList = new ArrayList();
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.GroupBox groupBox1;
private ComboBoxAutoComplete comboBoxAutoComplete2;
private Syncfusion.Windows.Forms.Tools.ComboBoxAutoComplete comboBoxAutoComplete1;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.comboBoxAutoComplete1 = new Syncfusion.Windows.Forms.Tools.ComboBoxAutoComplete();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.comboBoxAutoComplete2 = new Syncfusion.Windows.Forms.Tools.ComboBoxAutoComplete();
((System.ComponentModel.ISupportInitialize)(this.comboBoxAutoComplete1.AutoCompleteControl)).BeginInit();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.comboBoxAutoComplete2.AutoCompleteControl)).BeginInit();
this.SuspendLayout();
//
// comboBoxAutoComplete1
//
//
//
//
this.comboBoxAutoComplete1.AutoCompleteControl.AccessibleDescription = null;
this.comboBoxAutoComplete1.AutoCompleteControl.AccessibleName = null;
this.comboBoxAutoComplete1.AutoCompleteControl.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
this.comboBoxAutoComplete1.AutoCompleteControl.AdjustHeightToItemCount = true;
this.comboBoxAutoComplete1.AutoCompleteControl.AutoAddItem = false;
this.comboBoxAutoComplete1.AutoCompleteControl.AutoSerialize = true;
this.comboBoxAutoComplete1.AutoCompleteControl.CategoryName = "";
this.comboBoxAutoComplete1.AutoCompleteControl.ChangeDataManagerPosition = true;
this.comboBoxAutoComplete1.AutoCompleteControl.OverrideCombo = true;
this.comboBoxAutoComplete1.AutoCompleteControl.ParentForm = this.groupBox1;
this.comboBoxAutoComplete1.AutoCompleteControl.PreferredHeight = 200;
this.comboBoxAutoComplete1.AutoCompleteControl.SelectedIndex = -1;
this.comboBoxAutoComplete1.AutoCompleteControl.SelectedValue = "";
this.comboBoxAutoComplete1.AutoCompleteControl.ShowCloseButton = true;
this.comboBoxAutoComplete1.AutoCompleteControl.ShowGripper = true;
this.comboBoxAutoComplete1.DropDownWidth = 352;
this.comboBoxAutoComplete1.ForeColor = System.Drawing.SystemColors.HotTrack;
this.comboBoxAutoComplete1.ItemHeight = 13;
this.comboBoxAutoComplete1.Location = new System.Drawing.Point(64, 136);
this.comboBoxAutoComplete1.Name = "comboBoxAutoComplete1";
this.comboBoxAutoComplete1.ParentForm = this.groupBox1;
this.comboBoxAutoComplete1.Size = new System.Drawing.Size(240, 21);
this.comboBoxAutoComplete1.TabIndex = 4;
this.comboBoxAutoComplete1.UpdateComboSelectionProperties = true;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.comboBoxAutoComplete1);
this.groupBox1.Location = new System.Drawing.Point(88, 48);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(376, 216);
this.groupBox1.TabIndex = 6;
this.groupBox1.TabStop = false;
//
// label1
//
this.label1.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.label1.ImageIndex = 0;
this.label1.ImageList = this.imageList1;
this.label1.Location = new System.Drawing.Point(64, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(256, 80);
this.label1.TabIndex = 5;
this.label1.Text = "The ComboBoxAutoComplete control combines a combo box control with an AutoComplet" +
"e control to provide autocompletion for that instance of the combo box.";
//
// imageList1
//
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
this.imageList1.Images.SetKeyName(0, "");
//
// comboBoxAutoComplete2
//
//
//
//
this.comboBoxAutoComplete2.AutoCompleteControl.AccessibleDescription = null;
this.comboBoxAutoComplete2.AutoCompleteControl.AccessibleName = null;
this.comboBoxAutoComplete2.AutoCompleteControl.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
this.comboBoxAutoComplete2.AutoCompleteControl.AdjustHeightToItemCount = true;
this.comboBoxAutoComplete2.AutoCompleteControl.AutoAddItem = false;
this.comboBoxAutoComplete2.AutoCompleteControl.AutoSerialize = true;
this.comboBoxAutoComplete2.AutoCompleteControl.CategoryName = "";
this.comboBoxAutoComplete2.AutoCompleteControl.ChangeDataManagerPosition = true;
this.comboBoxAutoComplete2.AutoCompleteControl.OverrideCombo = true;
this.comboBoxAutoComplete2.AutoCompleteControl.ParentForm = this;
this.comboBoxAutoComplete2.AutoCompleteControl.PreferredHeight = 200;
this.comboBoxAutoComplete2.AutoCompleteControl.SelectedIndex = -1;
this.comboBoxAutoComplete2.AutoCompleteControl.SelectedValue = "";
this.comboBoxAutoComplete2.AutoCompleteControl.ShowCloseButton = true;
this.comboBoxAutoComplete2.AutoCompleteControl.ShowGripper = true;
this.comboBoxAutoComplete2.Location = new System.Drawing.Point(283, 282);
this.comboBoxAutoComplete2.Name = "comboBoxAutoComplete2";
this.comboBoxAutoComplete2.ParentForm = this;
this.comboBoxAutoComplete2.Size = new System.Drawing.Size(244, 21);
this.comboBoxAutoComplete2.TabIndex = 7;
this.comboBoxAutoComplete2.Text = "comboBoxAutoComplete2";
this.comboBoxAutoComplete2.UpdateComboSelectionProperties = true;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(200)))), ((int)(((byte)(219)))));
this.ClientSize = new System.Drawing.Size(552, 374);
this.Controls.Add(this.comboBoxAutoComplete2);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ComboBoxAutoCompleteDemo";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.comboBoxAutoComplete1.AutoCompleteControl)).EndInit();
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.comboBoxAutoComplete2.AutoCompleteControl)).EndInit();
this.ResumeLayout(false);

}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

#region DataSource
this.alphaList.AddRange(new String[]{"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z"
});

foreach(string s in this.alphaList)
{
for(int i = 0; i < 15; i++)
{
this.itemsList.Add(s + i.ToString());
}
}

this.comboBoxAutoComplete1.AutoCompleteControl.DataSource = this.itemsList;
#endregion
ComboBoxAutoComplete comboBoxAutoComplete3 = new ComboBoxAutoComplete();
comboBoxAutoComplete3.AutoCompleteControl.DataSource = this.itemsList;
this.Controls.Add(comboBoxAutoComplete3);
}



}
}

In the code above the comboboxautocomplete3 does not shown any items.

thanks
thanvir

3 Replies

JA JayaLakshmi Syncfusion Team July 9, 2007 11:39 AM UTC

Hi Thanvir,

Thank you for using Syncfusion products.

Could you please include the following code snippet to display the dropdown of ComboBoxAutoComplete control.

[C#]

this.comboBoxAutoComplete1.ParentForm = this;

The following sample illustrates this.

http://websamples.syncfusion.com/samples/Tools.Windows/F63650/main.htm

Kindly let me know if this helps.

Regards,
Jaya


TH Thanvir Hussain July 10, 2007 11:43 AM UTC

Hi,
I have inherited from the ComboboxAutoComplete to create a custom combobox. But the auto complete does not work. Whenever I click on the combo box I get a exception.

System.ArgumentOutOfRangeException was unhandled by user code
Message="Index and length must refer to a location within the string.\rParameter name: length"
Source="mscorlib"
ParamName="length"
StackTrace:
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at Syncfusion.Windows.Forms.Tools.ComboBoxAutoComplete.PreProcessMessage(Message& msg)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at MDIPricer.SpreadSheet.frmSpreadSheetPricer.CaptureTrade() in Y:\fox\foxclient\NewClient\MDIPricer\SpreadSheet\frmSpreadSheetPricer.cs:line 356
at MDIPricer.SpreadSheet.frmSpreadSheetPricer.m_Grid_CellButtonClicked(Object sender, GridCellButtonClickedEventArgs e) in Y:\fox\foxclient\NewClient\MDIPricer\SpreadSheet\frmSpreadSheetPricer.cs:line 345
at Syncfusion.Windows.Forms.Grid.GridControlBase.OnCellButtonClicked(GridCellButtonClickedEventArgs e)
at Syncfusion.Windows.Forms.Grid.GridControlBase.RaiseCellButtonClicked(Int32 rowIndex, Int32 colIndex, Int32 index, GridCellButton button)

thanks
thanvir

>Hi Thanvir,

Thank you for using Syncfusion products.

Could you please include the following code snippet to display the dropdown of ComboBoxAutoComplete control.

[C#]

this.comboBoxAutoComplete1.ParentForm = this;

The following sample illustrates this.

http://websamples.syncfusion.com/samples/Tools.Windows/F63650/main.htm

Kindly let me know if this helps.

Regards,
Jaya

BrokerCombo.zip


JA JayaLakshmi Syncfusion Team July 11, 2007 09:03 AM UTC


Hi Thanvir,

Thanks for providing us the CS file.

I have created a sample that is close to your requirement.

Could you please compile the below sample and let me know if you still running into issues?

http://websamples.syncfusion.com/samples/Tools.Windows/F63650_1/main.htm

Thanks for your patience.

Regards,
Jaya

Loader.
Live Chat Icon For mobile
Up arrow icon