日期:2014-05-18 浏览次数:21446 次
public Form1()
{
    initialize();
    this.combobox.DropDownStyle = DropDownList;
}
------解决方案--------------------
如果是WindowForm,就是要模仿Web网页的灰色效果,所以还要设置一下灰色的效果。单击时候还要去掉文本。
如果是WebForm,当我没说。
------解决方案--------------------
AutoCompleteStringCollection strings = new AutoCompleteStringCollection();  
strings.Add("123");
strings.Add("456");
...
ComBox.AutoCompleteCustomSource = strings;
               ComBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
               ComBox.AutoCompleteMode = AutoCompleteMode.Suggest;
------解决方案--------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace password
{
   public partial class Form1 : Form
   {
       public Form1()
       {
           InitializeComponent();
           this.comboBox1.LostFocus += new System.EventHandler(this.comboBox1_LostFocus);
           comboBox1.Text = "一段文字";
           comboBox1.Items.Add("123");
           comboBox1.Items.Add("abc");
       }
       private void comboBox1_LostFocus(object sender, EventArgs e)
       {
           if (comboBox1.Text == "")
           {
               comboBox1.Text = "一段文字";
           }
       }
       private void comboBox1_Click(object sender, EventArgs e)
       {
           if (comboBox1.Text == "一段文字")
           {
               comboBox1.Text = "";
           }
       }
   }
}