GetDicOfColumnValue获得数据表中前2列中不重复清单,以字典的形式返回。返回一个Dictionary(Of String,String)类型的字典。即使SQL语句返回的列字段类型不是字符串也会被转换为字符串。
语法:
GetDicOfColumnValue(sqlCmd)
参数名称 | 说明 |
sqlCmd | 字符类型,必填项。为要查询的SQL命令,该SQL必须返回2个字段的表。为字典的Key、Value值。 |
Vb.Net |
Dim tbl As SmGrid=Proj.CurrentSmGrid If tbl Is Nothing Then Return Dim strSQL As String="Select DicKeys,DicValues From SystemDictionary where ParentId=(Select DicID From SystemDictionary Where DicValues='政治面貌' and IsGroupName=1)" Dim dic As Dictionary(Of String,String)=tbl.DataTableHelp.Database.GetDicOfColumnValue(strSQL) '将返回的字典用来设置列的字典 tbl.Cols("PoliticalStatus").DataMap=dic '动态创建一个下拉清单控件 Dim cmb As New SmComboBox() '以一个字典设置控件的清单 cmb.ItemsBindingDictionary=dic '设置列的字典的下拉清单 tbl.Cols("PoliticalStatus").Editor=cmb |
C# |
SmGrid tbl = Proj.CurrentSmGrid; if (tbl == null) return; string strSQL = "Select DicKeys,DicValues From SystemDictionary where ParentId=(Select DicID From SystemDictionary Where DicValues='政治面貌' and IsGroupName=1)"; Dictionary<string, string> dic = tbl.DataTableHelp.Database.GetDicOfColumnValue(strSQL); // 将返回的字典用来设置列的字典 tbl.Cols["PoliticalStatus"].DataMap = dic; // 动态创建一个下拉清单控件 SmComboBox cmb = new SmComboBox(); // 以一个字典设置控件的清单 cmb.ItemsBindingDictionary = dic; // 设置列的字典的下拉清单 tbl.Cols["PoliticalStatus"].Editor = cmb; |