bluedreams

How to sort items in combobox?

Discussion created by bluedreams on May 1, 2013
Latest reply on May 19, 2013 by atomaly
Hi Everyone,

I want to ask spesific question about sorting items in combobox from A to Z. How can i perform sorting them?

If i cant sort them A to Z there is meaningless about the query that will be applied on it.

Waiting forward for your replies, kindly regards.

Tolga

Here are my vba codes:

Private Sub UserForm_Initialize()

Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pFeatLayer As IFeatureLayer
Dim pFeatClass As IFeatureClass
Dim pFields As IFields
Dim pField As IField
Dim i As Integer

Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap
Set pFeatLayer = pMap.Layer(0)
Set pFeatClass = pFeatLayer.FeatureClass
Set pFields = pFeatClass.Fields

For i = 0 To pFields.FieldCount - 1
cboMusteri.AddItem pFields.Field(i).Name


Next

Dim pLayer As ILayer
Set pLayer = pMap.Layer(0)
Set pFeatLayer = pLayer
Dim pFeature As IFeature
Dim pFeatCursor As IFeatureCursor
Dim pQueryFilter As IQueryFilter
Set pQueryFilter = New QueryFilter
pQueryFilter.SubFields = "MALIK"
Set pFeatCursor = pFeatLayer.Search(pQueryFilter, True)
Set pFeature = pFeatCursor.NextFeature

Dim j As Integer
Dim cDuplicate As Boolean
cDuplicate = False

cboMusteri.Clear

Do While Not pFeature Is Nothing
For j = 0 To cboMusteri.ListCount - 1
cDuplicate = False
If cboMusteri.List(j) = pFeature.Value(pFeature.Fields.FindField("MALIK")) & "" Then
cDuplicate = True
End If
Next j

If cDuplicate = False Then
cboMusteri.AddItem pFeature.Value(pFeature.Fields.FindField("MALIK")) & ""
End If
Set pFeature = pFeatCursor.NextFeature

Loop

Set pFeatCursor = Nothing
Set pFeature = Nothing
Set pFeatLayer = Nothing
Set pLayer = Nothing
Set pMap = Nothing
Set pMxDoc = Nothing
End Sub

Outcomes