以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助] (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=138327) |
-- 作者:swimmer01 -- 发布时间:2019/7/29 2:53:00 -- [求助] 老师,你好! 在窗口上有一组合框和一文本框,我想组合框选定后对文本框自动赋值 组合框的Enter事件代码 Dim xt0 As String=e.Form.Controls("ComboBox5").text Dim cmd As New SQLCommand Dim dt As DataTable Dim cmb As WinForm.ComboBox cmd.C cmd.CommandText = "S elect * FROM {zd_项目类别} where 项目类=\'"& xt0 &"\'" dt = cmd.ExecuteReader() cmb = e.Form.Controls("ComboBox1") cmb.ComboList= dt.GetComboListString("装置类","","代码") 组合框的SelectedIndexChanged事件代码(按帮助例子写的) Dim cm As WinForm.ComboBox = e.Form.Controls("ComboBox1") Dim dt As DataRow = cm.SelectedItem If dt IsNot Nothing Then e.Form.Controls("TextBox4").text = dt("代码") End If 出现以下错误信息: .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2019.7.21.1 错误所在事件:窗口,新建项目,ComboBox1,SelectedIndexChanged 详细错误信息: 无法将类型为“System.String”的对象强制转换为类型“Foxtable.DataRow”。 请老师帮忙解决一下,谢谢! |
-- 作者:有点蓝 -- 发布时间:2019/7/29 9:43:00 -- 组合框的SelectedIndexChanged事件代码 Dim cm As WinForm.ComboBox = e.Form.Controls("ComboBox1") Dim cmd As New SQLCommand Dim dt As DataTable Dim cmb As WinForm.ComboBox cmd.ConnectionName = "数据源" cmd.CommandText = "Select 代码 FROM {zd_项目类别} where 装置类=\'" & cm.SelectedItem & "\'" e.Form.Controls("TextBox4").text = cmd.ExecuteScalar() |
-- 作者:swimmer01 -- 发布时间:2019/7/29 13:57:00 -- 谢谢,老师! |