windows form 中,如何将DATAGRID中的一列,变成BUTTON?

godwu 2005-12-30 01:11:24
如题,将一列变成BUTTON
请指教.

谢谢
...全文
235 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnwd 2006-07-07
  • 打赏
  • 举报
回复
mark
godwu 2006-01-06
  • 打赏
  • 举报
回复
谢谢,试下先~
yrh2008sql 2006-01-06
  • 打赏
  • 举报
回复
Public MyCombo As New ComboBox()
Dim con As New SqlConnection("server=myservername;uid=myid;pwd=mypassword;database=northwind")
Dim daEmp As New SqlDataAdapter("Select * From Employees", con)

Public ds As New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler MyCombo.TextChanged, AddressOf Ctrls_TextChanged
'Fill ComboBox list.
MyCombo.Name = "MyCombo"
MyCombo.Visible = False
MyCombo.Items.Clear()
MyCombo.Items.Add("Sales Representative")
MyCombo.Items.Add("Inside Sales Coordinator")
MyCombo.Items.Add("Vice President, Sales")
MyCombo.Items.Add("Sales Manager")
MyCombo.Items.Add("Flunky")


daEmp.Fill(ds, "Employees")

'Set the RowHeight of the DataGrid to the height of the ComboBox.
DataGrid1.PreferredRowHeight = MyCombo.Height

DataGrid1.DataSource = ds

DataGrid1.DataMember = "Employees"
'Add ComboBox to the Control collection of the DataGrid.
DataGrid1.Controls.Add(MyCombo)
End Sub

Private Sub DataGrid1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles DataGrid1.Paint
If DataGrid1.CurrentCell.ColumnNumber = 3 Then
MyCombo.Width = DataGrid1.GetCurrentCellBounds.Width
End If
End Sub

Private Sub Ctrls_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
If DataGrid1.CurrentCell.ColumnNumber = 3 Then
MyCombo.Visible = False
If DataGrid1.Item(DataGrid1.CurrentCell) & "" = "" Then
SendKeys.Send("*")
End If
DataGrid1.Item(DataGrid1.CurrentCell) = MyCombo.Text
End If
End Sub

Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
If DataGrid1.CurrentCell.ColumnNumber = 3 Then
MyCombo.Visible = False
MyCombo.Width = 0
MyCombo.Left = DataGrid1.GetCurrentCellBounds.Left
MyCombo.Top = DataGrid1.GetCurrentCellBounds.Top
MyCombo.Text = DataGrid1.Item(DataGrid1.CurrentCell) & ""
MyCombo.Visible = True
Else
MyCombo.Visible = False
MyCombo.Width = 0
End If
End Sub

Private Sub DataGrid1_Scroll(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Scroll
MyCombo.Visible = False
MyCombo.Width = 0
End Sub

Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
MyCombo.Visible = False
MyCombo.Width = 0
End Sub
原理是一样的
weiyan19820315 2006-01-05
  • 打赏
  • 举报
回复
关注
godwu 2005-12-30
  • 打赏
  • 举报
回复
提示DataGridCellButtonClickEventArgs 没有定义
godwu 2005-12-30
  • 打赏
  • 举报
回复
这文章我也找到了,不过
Public Delegate Sub DataGridCellButtonClickEventHandler(ByVal sender As Object, ByVal e As DataGridCellButtonClickEventArgs)

这句在我机器上报错,提示没有定义,郁闷,调不过去
hamadou 2005-12-30
  • 打赏
  • 举报
回复
http://blog.csdn.net/hamadou/archive/2005/06/27/404043.aspx
基于EasyUI 官方的帮助。 Application 使用easyUI创建一个CRUD的应用 使用easyUI创建一个CRUD DataGrid 使用easyUI展开行详细编辑form创建CRUD应用 使用jQuery easyUI 创建一个 RSS Feed阅读器 Drag and Drop easyUI 基础的拖动和放置 使用easyUI创建一个拖放的购物车 使用easyUI创建一个课程表 Menu and Button 使用easyUI创建简单的菜单 使用easyUI创建Link Button 使用easyUI创建Menu Button 使用easyUI创建Split Button Layout 使用easyUI创建一个border layout在你的web页面 使用easyUI在panel创建复杂布局 使用easyUI创建折叠面板 使用easyUI创建Tabs标签 使用easyui创建tabs组件和动态添加 使用easyUI创建一个自动播放的tabs 使用easyUI创建XP风格左侧面板 DataGrid 使用easyUI转换HTML table到datagrid 使用easyUI给datagrid添加pagination 使用easyUI添加查询功能在datagrid 使用easyUI 添加toolbar到datagrid 使用easyUI 创建复杂的toolbar到datagrid 使用easyUI 为datagrid冻结 使用easyUI 动态改变datagrid的columns 使用easyUI 格式化datagrid easyUI 添加排序到datagrid easyUI 自定义排序datagrid easyUI 添加CheckBox选择到DataGrid easyUI自定义DataGrid分页栏 启用DataGrid行内编辑器 继承扩展DataGrid的editors easyUI在可编辑的datagrid计算两的值 easyUI合并DataGrid单元格 easyUI为datagrid创建自定义视图 easyUI datagrid显示摘要信息在页脚 easyUI 根据一些条件改变DataGrid 行背景颜色 easyUI 创建一个 Property Grid easyUI 展开DataGrid里面的行显示详细信息 easyUI 在主datagrid上创建子datagrid Window easyUI 我的第一个window easyUI 自定义window工具 easyUI window和布局 easyUI 创建Dialog对话框 easyUI Dialog自定义Toolbar和button Tree easyUI 从标记创建Tree easyUI 创建异步Tree easyUI 附加tree节点到tree easyUI 创建Tree和复选框Tree Node easyUI 拖动(Drag)和放置(Drop)Tree easyUI 加载parent/child节点到tree 转换tree标准格式数据 easyUI 创建一个基础的TreeGrid easyUI 创建复杂TreeGrid Form easyUI 通过ajax的方式提交Form easyUI 添加ComboTree 字段到一个 form easyui Form验证 easyUI 格式化ComboBox easyui 过滤ComboGrid 扩展 easyui DWR加载 easyUI 主题
• 1基本拖放 4 • 2构建购物车型拖放 5 • 3创建课程表 8 • 4菜单和按钮Menu and Button 10 o 4.1创建简单菜单 10 o 4.2创建连接按钮 11 o 4.3建立菜单按钮 12 o 4.4建立拆分按钮 13 • 5创建边框版面网页 15 o 5.1面板上的复合版面 16 o 5.2建立可折叠版面 17 o 5.3建立TABS 18 o 5.4动态添加tabs 19 o 5.5创建XP式样左面板 20 • 6 DataGrid 数据格 23 o 6.1 转换HTML表格到DataGrid 23 o 6.2 给DataGrid添加分页 25 o 6.3 得到DataGrid选择行 27 o 6.4 添加工具栏到DataGrid 28 o 6.5 DataGrid冻结 30 o 6.6 动态改变DataGrid 31 o 6.7 格式化DataGrid 32 o 6.8 添加排序到DataGrid 33 o 6.9 在DataGrid上的复选框 36 o 6.10 自定义DataGrid分页 37 o 6.11使DataGrid能编辑 38 o 6.12 DataGrid合并单元格 41 • 7 窗口 44 o 7.1 我第一个窗口 44 o 7.2 自定义窗口工具 45 o 7.3 Window和Layout 46 o 7.4 创建对话框 47 • 8 Tree 50 • 8.1从标记创建tree 51 • 8.2创建异步Tree 52 • 8.3 添加节点 55 • 8.4 创建带有checkbox节点的tree 57 • 9 表单 58 o 9.1 Ajax方式发送表单 58 o 9.2 给表单添加复合tree字段 59 o 9.3 验证表单 62 • 10 Documentation文档 65 o 10.1 Base 65  10.1.1 EasyLoader 66  10.1.2 Draggable 67  10.1.3 Droppable 69  10.1.4 Resizable 70 o 10.2 layout 71  10.2.1 Panel 71  10.2.2 tabs 76  10.2.3 accordion 79  10.2.4 layout 82 o 10.3 Menu and button 83 o 10.4 form 88 o 10.5 window 101 o 10.6 Datagrid and tree 107
• 1基本拖放 4 • 2构建购物车型拖放 5 • 3创建课程表 8 • 4菜单和按钮Menu and Button 10 o 4.1创建简单菜单 10 o 4.2创建连接按钮 11 o 4.3建立菜单按钮 12 o 4.4建立拆分按钮 13 • 5创建边框版面网页 15 o 5.1面板上的复合版面 16 o 5.2建立可折叠版面 17 o 5.3建立TABS 18 o 5.4动态添加tabs 19 o 5.5创建XP式样左面板 20 • 6 DataGrid 数据格 23 o 6.1 转换HTML表格到DataGrid 23 o 6.2 给DataGrid添加分页 25 o 6.3 得到DataGrid选择行 27 o 6.4 添加工具栏到DataGrid 28 o 6.5 DataGrid冻结 30 o 6.6 动态改变DataGrid 31 o 6.7 格式化DataGrid 32 o 6.8 添加排序到DataGrid 33 o 6.9 在DataGrid上的复选框 36 o 6.10 自定义DataGrid分页 37 o 6.11使DataGrid能编辑 38 o 6.12 DataGrid合并单元格 41 • 7 窗口 44 o 7.1 我第一个窗口 44 o 7.2 自定义窗口工具 45 o 7.3 Window和Layout 46 o 7.4 创建对话框 47 • 8 Tree 50 • 8.1从标记创建tree 51 • 8.2创建异步Tree 52 • 8.3 添加节点 55 • 8.4 创建带有checkbox节点的tree 57 • 9 表单 58 o 9.1 Ajax方式发送表单 58 o 9.2 给表单添加复合tree字段 59 o 9.3 验证表单 62 • 10 Documentation文档 65 o 10.1 Base 65  10.1.1 EasyLoader 66  10.1.2 Draggable 67  10.1.3 Droppable 69  10.1.4 Resizable 70 o 10.2 layout 71  10.2.1 Panel 71  10.2.2 tabs 76  10.2.3 accordion 79  10.2.4 layout 82 o 10.3 Menu and button 83 o 10.4 form 88 o 10.5 window 101 o 10.6 Datagrid and tree 107 从别人5分下下来的,我只要1分

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧