C#中TextBox實(shí)現(xiàn)輸入提示功能的方法
更新時間:2015年06月20日 12:10:44 作者:zhuzhao
這篇文章主要介紹了C#中TextBox實(shí)現(xiàn)輸入提示功能的方法,涉及C#中TextBox的相關(guān)操作技巧,需要的朋友可以參考下
本文實(shí)例講述了C#中TextBox實(shí)現(xiàn)輸入提示功能的方法。分享給大家供大家參考。具體如下:
設(shè)置TextBox的AutoCompleteSource的屬性為CustomSource,設(shè)置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#程序設(shè)計有所幫助。
您可能感興趣的文章:
- c# 設(shè)置TeeChart控件的提示文本
- C#瀏覽器提示跨域問題解決方案
- C#實(shí)現(xiàn)倒計時關(guān)閉提示框功能
- C#實(shí)現(xiàn)狀態(tài)欄提示信息功能的示例
- C# winForm實(shí)現(xiàn)的氣泡提示窗口功能示例
- 解決C#調(diào)用dll提示
- C#實(shí)現(xiàn)簡單的loading提示控件實(shí)例代碼
- c#消息提示框messagebox的詳解及使用
- C#程序提示“正由另一進(jìn)程使用,因此該進(jìn)程無法訪問該文件”的解決辦法
- C#提示:“在證書存儲區(qū)中找不到清單簽名證書”的解決方法
- c# 關(guān)閉窗體時提示的小例子
- 給 c# 程序員的十個重要提示
相關(guān)文章
C#數(shù)值轉(zhuǎn)換-顯式數(shù)值轉(zhuǎn)換表(參考)
就是在將一種類型轉(zhuǎn)換成另外一種類型時,需要額外的代碼來完成這種轉(zhuǎn)換。2013-04-04
C# 實(shí)現(xiàn)WebSocket服務(wù)端教程
這篇文章主要介紹了C# 實(shí)現(xiàn)WebSocket服務(wù)端教程,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-10-10

