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

  • 相关阅读:
    js获取前一页面连接的参数值
    window.onload()函数和jQuery中的document.ready()有什么区别
    jquery中$.get()提交和$.post()提交有区别吗?
    JQuery有几种选择器?
    jQuery 库中的 $() 是什么?
    JavaScript内置可用类型
    .JS 中 == 和 === 区别是什么
    undefined,null 和 undeclared 有什么区别
    JS中如何将页面重定向到另一个页面
    数据库设计中,一对多如何处理?
  • 原文地址:https://www.cnblogs.com/gbbwzz/p/7903218.html
Copyright © 2011-2022 走看看