问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

...自动把这一行所有字段值写入指定的文本框中

发布网友 发布时间:2024-09-30 17:04

我来回答

2个回答

热心网友 时间:2024-10-06 19:30

'List+Combo+Check三个样例 说明:此源码是我以前用FlxGd做的,同理可用于datagrid
Option Explicit

Private Sub Form_Load()
Dim x As Integer
With FlxGd
.ColAlignment(-1) = 1 'all Left alligned
For x = 1 To .Cols - 1
.TextMatrix(0, x) = "Col " + Str(x)
Next
For x = 1 To FlxGd.Rows - 1
.TextMatrix(x, 0) = "Row " + Str(x)
Next
.Row = 1
.Col = 1
.CellBackColor = &HC0FFFF 'lt. yellow
End With
Combo1_Load
List1_Load
Check1_Load
End Sub

Private Sub cmdAddRow_Click()
AddGridRow
End Sub

Private Sub cmdDelRow_Click()
DeleteGridRow
End Sub

Private Sub FlxGd_EnterCell()
FlxGd.CellBackColor = &HC0FFFF 'lt. yellow
FlxGd.Tag = "" 'clear temp storage
End Sub

Private Sub FlxGd_LeaveCell()
If FlxGd.Col = 2 Then
FlxGd = Format$(FlxGd, "#") 'alpha-number format
Else
If FlxGd.Col = 3 Then 'this is for Checkboxes
If Check1.Value = 0 Then
FlxGd.Text = "No"
End If
End If
FlxGd = Format$(FlxGd, "0.00")
End If
FlxGd.CellBackColor = &H80000005
End Sub

Private Sub FlxGd_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 46 '<Del>, clear cell
FlxGd.Tag = FlxGd 'assign to temp storage
FlxGd = ""
End Select
End Sub

Private Sub FlxGd_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 13 'ENTER key
Advance_Cell 'advance new cell
Case 8 'Backspace
If Len(FlxGd) Then
FlxGd = Left$(FlxGd, Len(FlxGd) - 1)
End If
Case 27 'ESC
If FlxGd.Tag > "" Then 'only if not NULL
FlxGd = FlxGd.Tag 'restore original text
End If
Case Else
FlxGd = FlxGd + Chr(KeyAscii)
End Select
End Sub

Private Sub FlxGd_Click()
If Combo1.Visible = True Then
Combo1.Visible = False
FlxGd.CellBackColor = &H80000005 'white
Else
If List1.Visible = True Then
List1.Visible = False
FlxGd.CellBackColor = &H80000005
Else
If Check1.Visible = True Then
Check1.Visible = False
FlxGd.CellBackColor = &H80000005
End If
End If
End If
If FlxGd.Col = 1 Then ' Position and size the ListBox, then show it.
List1.Width = FlxGd.CellWidth
List1.Left = FlxGd.CellLeft + FlxGd.Left
List1.Top = FlxGd.CellTop + FlxGd.Top
List1.Text = FlxGd.Text
List1.Visible = True
Else
If FlxGd.Col = 2 Then ' Position and size the ComboBox, then show it.
Combo1.Width = FlxGd.CellWidth
Combo1.Left = FlxGd.CellLeft + FlxGd.Left
Combo1.Top = FlxGd.CellTop + FlxGd.Top
Combo1.Text = FlxGd.Text
Combo1.Visible = True
Else
If FlxGd.Col = 3 Then ' Position and size the CheckBox, then show it.
Check1.Width = FlxGd.CellWidth
Check1.Left = FlxGd.CellLeft + FlxGd.Left
Check1.Top = FlxGd.CellTop + FlxGd.Top
If FlxGd.Text = "Yes" Then
Check1.Value = 1
Else
If FlxGd.Text = "No" Then
Check1.Value = 0
End If
End If
Check1.Visible = True
End If
End If
End If
End Sub

Private Sub Check1_Click() ' Place the selected Yes/No into the Cell and hide the CheckBox.
If FlxGd.Col = 3 Then
If Check1.Value = 1 Then
FlxGd.Text = "是"
Else
If Check1.Value = 0 Then
FlxGd.Text = "否"
End If
End If
Check1.Visible = False
End If
End Sub

Private Sub Check1_Load() ' Load the Checkbox.
Check1.Visible = False
Check1.Value = False
Check1.Caption = "请选择"
Check1.Width = FlxGd.CellWidth
End Sub

Private Sub List1_Load() ' Load the ListBox's list.
List1.Visible = False
List1.Width = FlxGd.CellWidth
List1.AddItem ""
List1.AddItem "小狗"
List1.AddItem "小猫"
List1.AddItem "金鱼"
List1.ListIndex = 0
End Sub

Private Sub List1_Click() ' Place the selected item into the Cell and hide the ListBox.
If FlxGd.Col = 1 Then
FlxGd.Text = List1.Text
List1.Visible = False
End If
End Sub

Private Sub Combo1_Click() ' Place the selected item into the Cell and hide the ComboBox.
If FlxGd.Col = 2 Then
FlxGd.Text = Combo1.Text
Combo1.Visible = False
End If
End Sub

Private Sub Combo1_Load() ' Load the ComboBox's list.
FlxGd.RowHeightMin = Combo1.Height
Combo1.Visible = False
Combo1.Width = FlxGd.CellWidth
Combo1.AddItem "1"
Combo1.AddItem "2"
Combo1.AddItem "3"
End Sub

Private Sub FlxGd_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim Row As Integer, Col As Integer
Row = FlxGd.MouseRow
Col = FlxGd.MouseCol
If Button = 2 And (Col = 0 Or Row = 0) Then
FlxGd.Col = IIf(Col = 0, 1, Col)
FlxGd.Row = IIf(Row = 0, 1, Row)
PopupMenu MnuFGridRows
End If
End Sub

Private Sub MnuFGridAddRow_Click()
AddGridRow
End Sub

Private Sub AddGridRow()
With FlxGd
.Rows = .Rows + 1
.Row = .Rows - 1
.TextMatrix(.Row, 0) = "Row " + Str(.Row)
End With
End Sub

Private Sub mnuDeleteGridRow_Click()
DeleteGridRow
End Sub

Private Sub DeleteGridRow()
Dim Row As Integer, n As Integer, x As Integer
With FlxGd
If .Rows > 2 Then 'make sure we don't del a row
Row = .Row
For n = 1 To .Cols - 1
If .TextMatrix(Row, n) > "" Then
x = 1
Exit For
End If
Next
If x Then
n = MsgBox("Data in Row" + Str$(Row) + ". Delete anyway?", vbYesNo, "Delete Row...")
End If
If x = 0 Or n = 6 Then 'no exist. data or YES
For n = .Row To .Rows - 2 'move exist data up 1 row
For x = 1 To FlxGd.Cols - 1
.TextMatrix(n, x) = .TextMatrix(n + 1, x)
Next
Next
If Row = .Rows - 1 Then 'set new cursor row
.Row = .Rows - 2
End If
.Rows = .Rows - 1 'delete last row
End If
End If
End With
End Sub

Private Sub End_Click()
End
End Sub

Private Sub Advance_Cell() 'advance to next cell
With FlxGd
.HighLight = flexHighlightNever 'turn off hi-lite
If .Col < .Cols - 1 Then
.Col = .Col + 1
Else
If .Row < .Rows - 1 Then
.Row = .Row + 1 'down 1 row
.Col = 1 'first column
Else
.Row = 1
.Col = 1
End If
End If
If .CellTop + .CellHeight > .Top + .Height Then
.TopRow = .TopRow + 1 'make sure row is visible
End If
.HighLight = flexHighlightAlways 'turn on hi-lite
End With
End Sub

热心网友 时间:2024-10-06 19:32

vb中选中datagrid中某一行,然后点击一个按钮,自动把这一行所有字段值写入指定的文本框中
回答这个问题:
Private Sub Command1_Click()
Dim k As Long
For k = 0 To dategrid1.Columns.Count - 1
text1.text=text1.text & "___" & dategrid1.Columns.Item(k).Text
Next
End Sub

后面问题类似,自己改改吧
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
Linux系统安装FTP服务器 Linux系统的网络文件共享 建筑的七盏明灯的内容简介 面向对象设计七大原则 简单说 交互设计七大定律 交互设计的“根”——七大定律 交互设计原则和理论2——七大定律 七大设计原则 附近的加油站有哪些 附近的加油站有哪些地方 ...如图所示,复选框选中几条数据后,将文本框的值保存到数据库中去_百度... 樊振东晋级四强了吗 ...如何对已选中复选框的值求和,并输出到一个文本框 梦见一直背着孩子在灶门前 ...选中多个 复选框 然后点击 按钮 才把选中的值 传到文本框里... nvidia geforce 8600gt的显卡可以玩孤岛危机2吗 CPU酷睿2双核1.8G内存1G 显卡nvidia geforce 8600GT玩天龙八部COU使用... nVIDIA GeForce 8600GT战斗版的显存容量是多少? ...一个文本框和一个多选框的内容输出到另一个文本框 我的显卡是NVIDIA Geforce 8600GT,其它硬件用360硬件大师测的是超了80... QQ安全盾被暂时冻结,怎样解冻?? 求初一下学期数学二元一次方程组和不等式题,不少于50道。 怎样使麻椒更麻 美丽说我的订单里面交易关闭的订单怎么删除 泌乳素高就一定是脑垂体瘤引起的吗 泌乳素瘤是垂体瘤吗 如何删除交易订单? 泌乳素与垂体瘤关系 请问图片上的狗狗是什么品种的??? word中如何给标题设置颜色和线性渐变word中如何给标题设置颜色和线性... 活螃蟹怎么保鲜 活螃蟹的保存方法 如图,这是泪痣吗? 苹果4s一不小心把一个APP删了,等到再去下载就这样,求解 很急的 谢谢 苹果4S 系统 6。0。1 登陆 QQ 微信 游戏等等软件 要我登陆 Apple id... 苹果4S用WIFI更新了一下系统,就这样子了 ,下载TUNIS,用手机连接电脑也没... 苹果4s不是国行有锁,去修手机的地方给配了一个卡贴,但是我把卡拔下来... 小米ai音箱怎么用喜马拉雅听书 喜马拉雅怎么把下载的声音导出来呢? 智加设计丨十五款加湿器设计​(建议收藏) 学生党看过来|送闺蜜100元的生日礼物推荐 22个最准怀女孩胎梦 小米max2为什么接受QQ或者微信消息都不会自动亮屏,也不在锁屏界面显示消... 小米Max2的分屏功能基于Android几版本? 为啥苹果录屏只有声音没有画面呢? 包皮过长不做手术有什么影响 包皮手术后吃些什么好术后怎么做对康复好 摩天轮的传说??越多越好 超实用的绳子打结方法,让你的生活更简单,便利 请问一下 把我的电脑显卡gtx960 4G拆下来安到老家机箱上,忘了什么型... 梦见悬崖上是什么意思?