Previous topicNext topic
Help > 开发指南 > SanMuGrid平台编程 > 主要对象 > Database > 数据处理 >
GetComboListOfColumnValue

GetComboListOfColumnValue根据SQL语句,返回第一列字段的集合,并返回“A|B|C|D”形式的字符串结果。这个与SQLGetComboListString所达到的效果类似。这个方法非常适合设置列的下拉清单和SmComboBox控件的下拉清单。

语法:

GetComboListOfColumnValue(sqlCmd)

参数名称  说明
 sqlCmd 字符类型,必填项。为要查询的SQL命令。

Vb.Net
Dim tbl As SmGrid=Proj.CurrentSmGrid
If tbl Is Nothing Then Return
Dim dr As RowData=tbl.CurrentRowData
If dr Is Nothing Then Return
    
Dim strSQL As String="select Distinct FullName from EmployeeInfo where FullName is not null"
'将SQL查询的结果赋值为列的下拉清单
tbl.Cols("FullName").ComboList=tbl.DataTableHelp.Database.GetComboListOfColumnValue(strSQL)
Proj.MsgDebug.Add(tbl.Cols("FullName").ComboList)

'返回结果:NewName|李某人12|万万1|陈某|aa|万万2|万万3|万万4|万万5|AB

C#
SmGrid tbl = Proj.CurrentSmGrid;
if (tbl == null)
    return;
RowData dr = tbl.CurrentRowData;
if (dr == null)
    return;

string strSQL = "select Distinct FullName from EmployeeInfo where FullName is not null";
// 将SQL查询的结果赋值为列的下拉清单
tbl.Cols["FullName"].ComboList = tbl.DataTableHelp.Database.GetComboListOfColumnValue(strSQL);
Proj.MsgDebug.Add(tbl.Cols["FullName"].ComboList);