2011-10-29 5 views
1

ドメインユーザーのために.netでオートコンプリートを行う方法はありますか?
意味、入力を開始してAdminを入力すると、それは管理者に入力されます。ドメインユーザー向けオートコンプリート

ありがとうございました。

+0

......ドメインのユーザー名を表示するために、このように試すことができますが、これはWebアプリケーションですか? Winforms? WPF? –

+0

これはwinformsです。 – DiGMi

答えて

3

確かに、すべての有効なドメインアカウント名のリストを保持し、そのデータソースでautocomplete(winformsの例)を使用することができます。

もちろん、機密情報を公開していることを意味します。

+0

ユーザー名は秘密ではありません:http://msmvps.com/blogs/alunj/archive/2011/10/17/1801349.aspx –

2

あなたは

namespace AutoCompleteTextBox 
{ 
    public partial class frmAuto : Form 
    { 
    public string strConnection = ConfigurationManager.AppSettings["ConnString"]; 
    AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection(); 
    public frmAuto() 
    { 
      InitializeComponent(); 
     } 

     private void frmAuto_Load(object sender, EventArgs e) 
     { 
       SqlDataReader dReader; 
       SqlConnection conn = new SqlConnection(); 
       conn.ConnectionString = strConnection; 
       SqlCommand cmd = new SqlCommand(); 
       cmd.Connection = conn; 
       cmd.CommandType = CommandType.Text; 
       cmd.CommandText ="Select distinct [Name] from [Names]" + " order by [Name] asc"; 
        conn.Open(); 
       dReader = cmd.ExecuteReader(); 
       if (dReader.HasRows == true) 
       { 
        while (dReader.Read()) 
        namesCollection.Add(dReader["Name"].ToString()); 

       } 
       else 
       { 
         MessageBox.Show("Data not found"); 
       } 
       dReader.Close(); 

       txtName.AutoCompleteMode = AutoCompleteMode.Suggest; 
       txtName.AutoCompleteSource = AutoCompleteSource.CustomSource; 
       txtName.AutoCompleteCustomSource = namesCollection; 

     } 
     private void btnCancel_Click(object sender, EventArgs e) 
     { 
        Application.Exit(); 
      } 
      private void btnOk_Click(object sender, EventArgs e) 
      { 
       MessageBox.Show(" this is autocomplete text box example"); 
      } 

     } 
} 
関連する問題