C# C窗口窗体组合框下拉列表和在组合框中写入的文本上显示的列表
我有一个从数据库绑定的组合框,现在我想要在组合框中写入文本时的下拉列表,并从列表中选择与组合框中写入的文本匹配的数据。 组合框绑定成功,但在其中更改文本时,不会根据写入的文本自动下拉列表。请告诉我怎么做。 下面给出了我的绑定源代码C# C窗口窗体组合框下拉列表和在组合框中写入的文本上显示的列表,c#,combobox,windows-forms-designer,C#,Combobox,Windows Forms Designer,我有一个从数据库绑定的组合框,现在我想要在组合框中写入文本时的下拉列表,并从列表中选择与组合框中写入的文本匹配的数据。 组合框绑定成功,但在其中更改文本时,不会根据写入的文本自动下拉列表。请告诉我怎么做。 下面给出了我的绑定源代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using Sys
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mateenwin
{
public partial class Sale : Form
{
public Sale()
{
InitializeComponent();
PaymentType_bind();
Customer_bind();
}
/// combobox bind method
public void PaymentType_bind()
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=mateenwin;User ID=sa;Password=123");
SqlCommand command = new SqlCommand("Select * from PaymentType", con);
SqlDataAdapter adp = new SqlDataAdapter(command);
DataTable dt = new DataTable();
adp.Fill(dt);
this.comboBox1.DataSource = dt;
this.comboBox1.DisplayMember = "Payment_Type";
this.comboBox1.ValueMember = "Payment_Type_ID";
}
ComboBox有一个名为AutoCompleteMode的属性。它表示一个以书面文本开始的值。我向你推荐的。还可以将AutoCompleteSource设置为您的数据库。DropDownStyle=DropDown,这样您就不希望它完成文本。只是一个具有适当值的列表?