首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

datagridview 平添按钮列 除了DataGridViewButtonColumn,还有别的方法吗

2012-12-23 
datagridview 添加按钮列 除了DataGridViewButtonColumn,还有别的方法吗datagridview 添加按钮列 除了Data

datagridview 添加按钮列 除了DataGridViewButtonColumn,还有别的方法吗
datagridview 添加按钮列 除了DataGridViewButtonColumn,还有别的方法吗
[解决办法]
还可以在属性面板那里加 添加列,把列属性设为按钮列
[解决办法]
拖一个Button到窗体上,Visible 为False
如下处理事件,则当鼠标点击到第三列中时,当前行显示Button

 Private Sub DataGridView1_CellEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEnter
        Me.DataGridView1.Controls.Clear()        
            if DataGridView1.CurrentCellAddress.X = 2 then   '第三列中显示Button
                    Button1.Visible = True                             '设置控件允许显示 
                    Button1.Enabled = True
                    Button1.Width = Me.DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, True).Height       '获取单元格高并设置为btn的宽 
                    Button1.Height = Me.DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, True).Height      '获取单元格高并设置为btn的高 
                    Me.DataGridView1.Controls.Add(Button1)
                    Button1.Location = New System.Drawing.Point(((Me.DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, True).Right) - (Button1.Width)), Me.DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, True).Y)   '设置btn显示位置 
            end if
end sub

[解决办法]
唉,都不能满足需要了

热点排行