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

  • 相关阅读:
    Sql Server--如何自动备份数据
    Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AI" in the equal to operation.
    GET方法和POST方法的区别,Get方法到底可传递的字符串的最大长度是多少?
    Specialization For SCCM
    Fullscreen API:全屏操作
    How to enable remote connections to SQL Server
    Advanced Installer
    ajax跨域请求webservice webconfig配置
    SharePoint Resize app
    Sharepoint 开启App 配置App
  • 原文地址:https://www.cnblogs.com/gbbwzz/p/7903218.html
Copyright © 2020-2023  润新知