zoukankan      html  css  js  c++  java
  • winform知识点集合

    1.跨窗体传值:

     private void button1_Click(object sender, EventArgs e)
            {
                Form2 f2 = new Form2(textBox1.Text);
                f2.Show();
            }

     public Form2(string s)   
            {
                InitializeComponent();

                label1.Text = s;
            }

    2.listview属性

    FullRowSelect:鼠标选中

    checkbox:选项框

    gridlines:表格

    3.绑定数据:

    private string _NationCode;

            public string NationCode
            {
                get { return _NationCode; }
                set { _NationCode = value; }
            }

     private string _NationName;

            public string NationName
            {
                get { return _NationName; }
                set { _NationName = value; }
            }        //给一个nationcode给一个nationname

    查询nation表方法:

     public List<Nation> SelectAll()
            {
                List<Nation> nlist = new List<Nation>();

                cmd.CommandText = "select *from Nation";

    //调用方法

     public Form1()
            {
                InitializeComponent();
                List<Nation> nlist = new NationData().SelectAll();
                comboBox1.DataSource = nlist;
                comboBox1.DisplayMember = "NationName";
                comboBox1.ValueMember = "NationCode";
                comboBox1.SelectedValue = "N002";
                List<Nation> nlist2 = new NationData().SelectAll();
                listBox1.DataSource = nlist2;
                listBox1.DisplayMember = "NationName";
                listBox1.ValueMember = "NationCode";

            }

                conn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    Nation n = new Nation();
                    n.NationCode = dr[0].ToString();
                    n.NationName = dr[1].ToString();
                    nlist.Add(n);
                }
                conn.Close();
                return nlist;
            }

  • 相关阅读:
    设计模式(四)——代理、模板、命令、访问者、迭代器、观察者
    设计模式(三)——桥接、装饰、组合、外观、享元
    设计模式(二)——工厂、原型、建造者、适配器
    设计模式(一)——设计原则、单例
    MySQL索引原理和锁
    MySQL(四)——索引使用等
    【摘】1范数与2范数优缺
    随机森林相关
    一些SEED数据集介绍
    神经网络的非线性
  • 原文地址:https://www.cnblogs.com/gbbwzz/p/7903218.html
Copyright © 2011-2022 走看看