' 函数名 :DataAddToCombobox ' 函数功能:将传入的对象添加至下拉列表中 ' 传入参数:objInfo:数据对象,CmbObj:下拉列表框对象,AddColName:要添加的列名,IsAll:是否添加"全部"字段 ' 返回值 : ' 制作人 :zzz ' 制作日期:2007-04-10 ' 说 明 : Public Sub DataAddToCombobox() Sub DataAddToCombobox(ByVal objInfo As Object, ByRef CmbObj As ComboBox, _ ByVal AddColName As String, Optional ByVal IsAll As Boolean = False) CmbObj.Items.Clear() Dim i As Int16 Try If objInfo.GetType.ToString = "System.Data.DataTable" Then '将DataTable的数据添加到下拉列表中 If objInfo.Rows.Count = 0 Then Throw New Exception("Error In DataAddToCombobox!!!" & vbCrLf & _ "Source:objInfo" + " Message:未找到有效的数据!") Exit Try End If If IsAll = True Then CmbObj.Items.Add("全部") End If For i = 0 To objInfo.Rows.Count - 1 CmbObj.Items.Add(Convert.ToString(objInfo.Rows(i)(AddColName)).Trim) Next ElseIf objInfo.GetType.ToString = "System.String[]" Then '将String数组的数据添加到下拉列表中 If UBound(objInfo) < 0 Then Throw New Exception("Error In DataAddToCombobox!!!" & vbCrLf & _ "Source:objInfo" + " Message:未找到有效的数据!") Exit Try End If If IsAll = True Then CmbObj.Items.Add("全部") End If For i = 0 To UBound(objInfo) CmbObj.Items.Add(Convert.ToString(objInfo(i)).Trim) Next ElseIf objInfo.GetType.ToString = "" Then End If CmbObj.SelectedIndex = 0 Catch ex As Exception Throw New Exception("Error In DataAddToCombobox!!!" & vbCrLf & _ "Source:" & ex.Source + ex.Message) Finally End Try End Sub