从后面的代码创建网格视图(动态) [英] creating grid view from code behind(dynamically)

查看:72
本文介绍了从后面的代码创建网格视图(动态)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何动态创建网格视图? 用户可能会添加任意数量的网格视图,因此在单击按钮时我想添加网格视图,
我该怎么做.(

在此先感谢

Hi,
how do i create grid view dynamically,?
there are chances that user may add any number of grid views,so on click of button i want to add grid view,
how will i do that.(

thanks in advance

推荐答案

看看这个

单击此处
Have a look at this

click here


private void button1_Click(object sender, EventArgs e)
      {
          DataGridView grd = new DataGridView();
          Point pt = new Point(0, 0);
          grd.RowCount = 2;
          grd.ColumnCount = 2;
          grd.Location = pt;
          grd.Visible = true;
          this.Controls.Add(grd);
      }



只需设置所需的所有DataGridView属性.希望这可以帮助. :)



Just set all the DataGridView properties you need. Hope this helps. :)


看看:
如何在网格视图中动态创建模板列 [
have a look at:
How to create template columns dynamically in a grid view[^]


这篇关于从后面的代码创建网格视图(动态)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆