Winform窗体

这是我之前写代码的时候被卡住的一些小知识点,看到这篇博客的人,如果有用,我很高兴很够帮助到你,如果对你没有帮助,那么请你路过就好

1.Winform窗体跳转

       Show(非模态显示) 可以操作其他窗体,在弹出窗口和调用窗口之间随意切换,比如:弹出Form2窗体了,还是原本的Form窗体进行操作

       ShowDialog(模态显示)  不允许操纵其他窗体

       MdiParent属性的作用:将某个窗体的IsMdiContainer属性设置为true,在跳转窗体的时候写上  fm.MdiParent=this;如下所示,注意:MdiParent只能和show()一起使用,不能和ShowDialog()一起使用

   

 2. 窗体窗体,通过Owner属性窗体

            左图为启动窗体Form1  右图为调用窗体UserB    (在启动窗体中定义一个public公有变量,并赋值。)

 

3.DataGridView只显示指定的列 (this.dataGridView1.AutoGenerateColumns=false)

     

 

4.selctionmode属性FullRowSelect选中整行

5. 获取dataGridView列表中的某个值

         string  aa=this.dataGridView1.Row[ i ].Cell[ j ].Value.ToString();    第 i 行,第 j 列的值  

         string   bb=this.dataGridView1.CurrentRow.cells[0].value.ToString();     当前行某一列的值

         int row=int.Parse(this.dataGridView1.CurrentCell.RowIndex.ToString())    当前第几行

         int  column=int.Parse(this.dataGridView1.CurrentCell.ColumnIndex.ToString())  当前第几列

6. SqlServer取得别名也可以绑定DataGridView控件

7. ExecteNonQuery() 不能用来做查询,只能是增删改

8.Winfrom下拉框绑定数据的关键字段

         this.下拉框名称.DisplayMember=“Name"

         this.下拉框名称.ValueMember=“ID"

         

                        

 

posted @ 2018-12-18 15:13  kuangx  阅读(779)  评论(0编辑  收藏  举报