Public Sub LoadTblToCbx(inputTable As ITable, inputFieldName As String, cbxInput As System.Windows.Forms.ComboBox) ' Create the query filter. Dim queryFilter As IQueryFilter2 = New QueryFilter ' Select the fields to be returned queryFilter.SubFields = inputFieldName ' Set the filter to return only searchable queryFilter.WhereClause = """IsSearchable"" = 'Y'" ' Use the PostfixClause to sort ascending Dim queryFilterDef As IQueryFilterDefinition2 = CType(queryFilter, IQueryFilterDefinition2) queryFilterDef.PostfixClause = "ORDER BY ""SortSequence""" ' Output the returned feature class name. Dim fieldIndex As Integer = inputTable.FindField(inputFieldName) Dim cursor As ICursor = inputTable.Search(queryFilter, True) Dim row As IRow = cursor.NextRow() While Not row Is Nothing Dim field As String = Convert.ToString(row.Value(fieldIndex)) cbxInput.Items.Add(field) row = cursor.NextRow() End While Marshal.FinalReleaseComObject(cursor) End Sub
Solved! Go to Solution.
Public Sub LoadTblToCbx(inputTable As ITable, searchField As String, whereClause As String, sortField As String, cbxInput As System.Windows.Forms.ComboBox) 'CJD 11/15/2012 - uses SQL statements to query a geodatabase table and write selective values to a combobox cbxInput.Items.Clear() 'clear old comboboxitmes Dim queryFilter As IQueryFilter2 = New QueryFilter 'Create the query filter. 'Select the fields to be returned queryFilter.SubFields = searchField & "," & sortField 'Set the field to query queryFilter.WhereClause = whereClause ' Use the PostfixClause to sort ascending Dim queryFilterDef As IQueryFilterDefinition2 = CType(queryFilter, IQueryFilterDefinition2) queryFilterDef.PostfixClause = "ORDER BY " & sortField Dim fieldIndex As Integer = inputTable.FindField(searchField) Dim cursor As ICursor = inputTable.Search(queryFilter, True) Dim row As IRow = cursor.NextRow() While Not row Is Nothing Dim field As String = Convert.ToString(row.Value(fieldIndex)) cbxInput.Items.Add(field) row = cursor.NextRow() End While Marshal.FinalReleaseComObject(cursor) End Sub
Corbin:
Can you please post your code when you have it working with the file geodatabase?
Lance:
How come the NIM I referenced says that this functionality is on-hold for file geodatabases, but you say it actually does work?