• 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;
            }

  • 相关阅读:
    hdu 1176 免费馅饼
    http://codeforces.com/contest/741/problem/B B. Arpa's weak amphitheater and Mehrdad's valuable Hoses
    瞎搞题
    1D1D决策单调性dp
    整体二分(POJ2104 静态第k大查询)
    B
    http://codeforces.com/contest/776/problem/G
    http://codeforces.com/contest/776/problem/D 2-sat
    bzoj1492(cdq分治 && 平衡树维护dp)
    F. Bear and Bowling 4(斜率优化)
  • 原文地址:https://www.cnblogs.com/gbbwzz/p/7903218.html
Copyright © 2020-2023  润新知