C#中TextBox完成輸出提醒功效的辦法。本站提示廣大學習愛好者:(C#中TextBox完成輸出提醒功效的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#中TextBox完成輸出提醒功效的辦法正文
本文實例講述了C#中TextBox完成輸出提醒功效的辦法。分享給年夜家供年夜家參考。詳細以下:
設置TextBox的AutoCompleteSource的屬性為CustomSource,設置TextBox的AutoCompleteMode屬性為SuggestAppend。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WindowsApplication7.DataSet1TableAdapters;
namespace WindowsApplication7
{
public partial class Form1 : Form
{
DataSet1 ds = new DataSet1();
CustomersTableAdapter adpter = new CustomersTableAdapter();
public Form1()
{
InitializeComponent();
}
private void BuildAutoCompleteList()
{
AutoCompleteStringCollection filterVals = new AutoCompleteStringCollection();
foreach (DataRow dr in ds.Customers)
{
filterVals.Add(dr["CompanyName"].ToString());
}
txtCompanyName.AutoCompleteCustomSource = filterVals;
}
private void Form1_Load(object sender, EventArgs e)
{
adpter.Fill(ds.Customers);
BuildAutoCompleteList();
}
}
}
願望本文所述對年夜家的C#法式設計有所贊助。