Re: Combobox Sorting
- From: Argusy <argusy@xxxxxxxxxxxxxxx>
- Date: Tue, 31 Jul 2007 20:31:48 +0930
LondonLad wrote:
Hi
I am using this code provided by MikeD and I want to sort the Combobox entries so I added the line as shown **
This give an error "Can't assign to Read-Only property" How can I sort the Combobox? can you help please
Private Sub Form_Load()
Dim lFileNum As Long
Dim sFileName As String
Dim saItems() As String
Dim sTemp As String
Dim Index As Long
On Error GoTo EH
cboTest.Text = "Select Item"
cboTest.ListIndex = -1
**
cboTest.Sorted = True
**
txtItemToAdd.Text = ""
cmdAdd.Enabled = False
If Right$(App.Path, 1) <> "\" Then
sFileName = App.Path & "\" & CBO_LIST_FILENAME
Else
sFileName = App.Path & CBO_LIST_FILENAME
End If
lFileNum = FreeFile
'Be prepared for a file not found error
Open sFileName For Input As lFileNum
sTemp = Input(LOF(lFileNum), lFileNum)
Close lFileNum
saItems = Split(sTemp, vbCrLf)
For Index = LBound(saItems) To UBound(saItems)
If Len(saItems(Index)) > 0 Then
cboTest.AddItem saItems(Index)
End If
Next
Exit Sub
EH:
Close lFileNum
If Err.Number <> 53 Then
MsgBox Err.Description
End If
End Sub
open your program in the IDE and select the errant combobox on whatever form it's on.
Change the "Sorted" property in the combobox properties box to true.
As the message says "Can't assign to Read-Only property"
Any message that comes back with that, means you have to preset whatever control that generated it, via the property in the properties box when you're developing your program.
That's the simple fix.
There are other means to do what you want, but you need to be a VERY experienced programmer, in classing and exposing properties, to understand it.
I'm not, so if you're after that sort of programming, you need one of the MVPs in the forum to explain it. One of 'em will surface if you are prepared to wait.
Argusy
.
- Prev by Date: Re: [Winsock] Server trunks data
- Next by Date: Re: Copy...
- Previous by thread: Re: Combobox Sorting
- Next by thread: Re: Combobox Sorting
- Index(es):
Relevant Pages
|