以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助][已解决]菜单的列表项目获取出错  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=50036)

--  作者:wxfjamdc
--  发布时间:2014/4/28 12:39:00
--  [求助][已解决]菜单的列表项目获取出错
菜单有一个列表项目,希望能自动获取内容,测试代码如下
Dim cmd As  SQLCommand
cmd.C
Dim dt As DataTable
cmd.CommandText = "SELECT DISTINCT 区域 From {客户资料}"
dt = cmd.ExecuteReader()
Dim cmb As RibbonMenu.ComboBox = RibbonTabs("内容查询").Groups("精确查询").Items("辖区查询")
Dim vals() As String = dt.GetComboListString("区域").Split("|")
With RibbonTabs("内容查询").Groups("精确查询").Items("辖区查询")
    .Items.Clear
    For Each val As String In vals
        Dim btn As new RibbonMenu.Button(val)
        btn.text = val
        cmb.Items.Add(btn)
    Next
    .Text= Vals(0)
End With
提示:System.NullReferenceException:未将对象引用设置到对象的实例,



已解决:问题是Dim cmd As New SQLCommand 少了3字母图片点击可在新窗口打开查看
[此贴子已经被作者于2014-4-29 10:03:09编辑过]

--  作者:Bin
--  发布时间:2014/4/28 14:05:00
--  
Dim cmd As  SQLCommand
cmd.C
Dim dt As DataTable
cmd.CommandText = "SELECT DISTINCT 区域 From {客户资料}"
dt = cmd.ExecuteReader()
Dim cmb As RibbonMenu.ComboBox = RibbonTabs("内容查询").Groups("精确查询").Items("辖区查询")
Dim vals() As String = dt.GetComboListString("区域").Split("|")
With RibbonTabs("内容查询").Groups("精确查询").Items("辖区查询")
    .Items.Clear
    For Each val As String In vals
        Dim btn As new RibbonMenu.Button(val)
        btn.text = val
        cmb.Items.Add(btn)
    Next
if Vals.length>0 then
 .Text= Vals(0)
end if
End Wit