以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]如何根据表查询结果得到的记录动态生成按钮? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=130731) |
-- 作者:lunengcheng -- 发布时间:2019/1/30 16:07:00 -- [求助]如何根据表查询结果得到的记录动态生成按钮? 各位老师前辈好,我写了下面的代码,想根据查询结果得到的记录动态生成按钮,下面的代码可以动态生成按钮,但是只能生成一个按钮,查询得到的记录结果是有多条记录的,现在查不出什么原因,希望老师能帮忙看一下! \'动态添加语音按钮 Dim ld1 As String Dim cjr1 As String = User_Name Dim cmd1 As New SQLCommand cmd1.CommandText = "S-elect 语音话术标题 From {YW_话术管理语音记录} Where 创建人 = \'" & cjr1 & "\'" ld1 = cmd1.ExecuteScalar() If ld1 <> Nothing Then Dim bt As WinForm.Button bt = e.Form.CreateControl(ld1, ControlTypeEnum.Button) bt.Left = 30 bt.Top = 30 bt.Width = 200 bt.Height = 45 bt.text = ld1 e.Form.Controls("TabControl1").Tabpages(0).AddControl(bt) End If [此贴子已经被作者于2019/1/30 16:07:12编辑过]
|
-- 作者:有点蓝 -- 发布时间:2019/1/30 17:38:00 -- Dim cjr1 As String = User_Name Dim cmd1 As New SQLCommand cmd1.CommandText = "S-elect 语音话术标题 From {YW_话术管理语音记录} Where 创建人 = \'" & cjr1 & "\'" Dim dt As DataTable = cmd1.ExecuteReader() Dim idx As Integer = 0 For Each dr As DataRow In dt.DataRows Dim bt As WinForm.Button bt = e.Form.CreateControl(dr("语音话术标题"), ControlTypeEnum.Button) bt.Left = 30 + idx*200 bt.Top = 30 bt.Width = 200 bt.Height = 45 bt.text = dr("语音话术标题") e.Form.Controls("TabControl1").Tabpages(0).AddControl(bt) idx = idx +1 Next |