在GridView中动态添加的列 [英] dynamically added column in GridView

查看:91
本文介绍了在GridView中动态添加的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友
我正在gridview中动态添加列,这工作得很好.
但我也想在不动态的网格视图中添加列之前添加复选框.
任何人都可以帮助我如何在gridview中添加复选框作为第一列,然后将动态添加所有列.
感谢

Hello friends
I m adding columns in gridview dynamically which is working perfectly fine.
but i also want to add checkbox before adding columns in grid view which is not dynamic.
can anyone help me how to add checkbox in gridview as first column and then all columns will be addded dynamically.
Thanks

推荐答案

我假设您正在使用WinForms,并且您引用的是DataGridView(您应该使用所使用的UI框架标记问题),然后可以添加第一列使用编辑器.在DataGridView的右上角应该有一个小箭头,允许您在设计器中添加和编辑列.

希望这对您有帮助
I assume you are using WinForms and you are referring to the DataGridView(you should tag your question with the UI framework you are using)then you can add the first column using the editor. There should be a small arrow at the top right on the DataGridView which allows you to add and edit columns in the designer.

Hope this helps


绑定源应该具有一个布尔属性,该属性将绑定到一个复选框,该复选框确定是否显示其他动态创建的属性.
The binding source should have a boolean property, which will be bound to a check box, that determines whether or not the other dynamically created properties are displayed.


我有一段时间没有在C#中做到这一点,但是在VB中会是这样(如果我没记错的话,C#方法非常接近)

I haven''t done that in C# in a while, but in VB it would be something like this (if I remember right the C# method is pretty close)

Dim gridCheck As New DataGridViewCheckBoxColumn

        With gridCheck
            .HeaderText = ""
            .Name = "gridCheck"
            .Width = 30
            .HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        End With

dgvWhatEver.Columns.Insert(0, gridCheck)


这篇关于在GridView中动态添加的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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