问题一:密码确认。好比一个注册表。密码和密码确认填完后如果密码确认和密码不一致的话不可以进行下边的操作。求例题代码。问题二:好比QQ登录器,如果你以前登录过,那他那个文本框里就会有存。然后你输入开头的几个,他就会直接吧以前你登录过的列出来求例题代码。问题三:我想让窗口启动后上边某个按钮上的字体循环变换颜色不停止。...是按钮不是图片框求解问题四:用哪个按钮可以点击后出来一个比如另存为那样的对话框?。。求解。。

解决方案 »

  1.   

    呵呵,问题真不少!1、确认密码 框做 文本改变事件 就可以,判断一下,符合你逻辑要求,你才启用 下面的控件,
    2、登录验证通过(登录成功),保存用户名到一个文件(txt,xml,注册表)都可以,窗口加载,读取文件中的用户名,供用户选择就可以了
    3、timer 很容易搞定
    4、系统有保存文件对话框,和 打开文件对话框最后:建议楼主还是多看看书
      

  2.   

    其他几个问题要多看书
    目前你问题四是可以解决用SaveFileDialog
      

  3.   

    其实QQ的那个QQ号列表是通过遍历我的文档\Tencent Files里面的文件夹来添加到Combobox的。
    当然你也可以用其他方式,例如XML,反序列化等
      

  4.   

    我可以传参数过去。那边Images集合里能收到。但是程序运行后,你如果输入的在集合里相匹配的话我想让他自己把后边的以选种的样式列出来 或 直接给我个下拉列表框选择
      

  5.   


    请研究使用ComboBox的AutoCompleteMode,AutoCompleteSource,AutoCompleteCustomerSource属性
      

  6.   


    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    using System.IO;namespace WindowsFormsApplication7
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            /// <summary>
            /// 登陆单击事件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button1_Click(object sender, EventArgs e)
            {
                Login();
            }     
            /// <summary>
            /// 登陆
            /// </summary>
            private void Login()
            {
                //获得用户输入的用户名        
                String name = this.cboName.Text;
                //储存数据库中的密码
                String paw = null;
                bool isExists = false;
                //创建查询语句
                String sql = String.Format("select uPass from dbo.TBL_User where uName = '{0}'", name);
                SqlConnection con = null;
                SqlDataReader dr = null;
                try
                {
                    //创建连接
                    con = new SqlConnection("Data Source=.;Initial Catalog=XX;Integrated Security=True");
                    //打开数据库
                    con.Open();
                    //创建sqlcommand对象
                    SqlCommand com = new SqlCommand(sql, con);
                    dr = com.ExecuteReader();
                    if (dr.Read())
                    {
                        paw = dr["uPass"].ToString();
                        isExists = true;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    dr.Close();
                    con.Close();
                }
                if (isExists)
                {
                    if (this.txtPaw.Text == paw)
                    {
                        MessageBox.Show("登陆成功!");
                        //登陆成功保存登陆信息
                        SaveName();
                    }
                    else
                    {
                        MessageBox.Show("密码错误!");
                    }
                }
                else
                {
                    MessageBox.Show("用户名有误!");
                }
            }
              /// <summary>
            /// 保存登陆成功的用户名称
            /// </summary>
            private void SaveName()
            {
                try
                {
                    FileStream fs = new FileStream("config.text", FileMode.Open);
                    StreamWriter sw = new StreamWriter(fs,Encoding.UTF8);              
                    foreach (String item in this.cboName.Items)
                    {
                        sw.WriteLine(item);
                    }
                    sw.WriteLine(this.cboName.Text);
                    sw.Close();
                    fs.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }        }
          
            /// <summary>
            /// 读取登陆信息
            /// </summary>
            private void ReadName()
            {
                try
                {
                    FileStream fs = new FileStream("config.text", FileMode.Open);
                    StreamReader sw = new StreamReader(fs, Encoding.UTF8);
                    while (!sw.EndOfStream)
                    {
                        this.cboName.Items.Add(sw.ReadLine());
                    }
                    sw.Close();
                    fs.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }  
            }
            /// <summary>
            /// 加载登陆信息
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void Form1_Load(object sender, EventArgs e)
            {
                ReadName();
                //最后一次登陆的人
                this.cboName.SelectedIndex = this.cboName.Items.Count - 1;
                
            }
            /// <summary>
            /// button变色
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void timer1_Tick(object sender, EventArgs e)
            {
                int r = 0,g=0,b=0;            Random rd = new Random();
                r =rd.Next(0,255);
                g = rd.Next(0, 255);
                b = rd.Next(0, 255);
                this.button1.ForeColor = Color.FromArgb(r, g, b); 
            }
            /// <summary>
            /// 
            /// 另存为.....
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button2_Click(object sender, EventArgs e)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.ShowDialog();
            }    }
    }
      

  7.   


    四个问题都解决了,唯一没解决的就是那个按下键盘就弹出对应的值这个貌似ComBoBox没这么强大--!别的方法倒是有~懒的写将就下
      

  8.   

    这一个问题也可以解决的,你向窗体订阅一个按键拦截事件 就行了,这样在事件处理方法里对每一次按键事件
    进行判断是否合乎要求来显示ComBox里的值
      

  9.   

    对啊,我很同意yia886的观点,我以前也看过,他那种就是很好,运用拦截事件
      

  10.   


    我也想到过,但是你在输入的时候如何弹出下拉表!像QQ那种登陆方法comboBox貌似实现不了!不知道这位兄弟能搞定不?