I have set for a combobox the initialvalue. How do I get it to display as default value. Currently the list shown is the first element in the list and not the initialvalue. I have set list index to 0 and -1. What is the value of initial value.
In the Open event, set the ListIndex that you want.
I do and I do not get the InitialValue.
What do I have to do to get the InitialValue?
ok, so I just created a combobox with no events implemented, and I set the InitialValue to:
When I run the project, the ComboBox starts out with the word “One” in the text field and a menu of options labelled “One”, “Two” and “Three”
Could you look at that project and tell me what’s different about the way you’re doing it?
My guess is that Arthur is talking about ListIndex, based on:
If that is the case, if you want Greg’s example to show Two instead of One as default you add this to Open event:
me.ListIndex = 1 // because is 0 based, 0 is One, 1 is Two and 2 would be Three
I also load in an array. This becomes the list.
CRGrmCmBox is the Combobox.
The code following is in a method of the window
For i = 0 To GrXCnt
trsfRow.dagta(i) = GrList.GLHeading(i)
CRGrmCmBox.InitialValue = Join( trsfRow.dagta, DSep )
For i = 0 To GrList.GrmWrdArray.Ubound
trsfRow = GrList.GetRIc( i, False )
CRGrmCmBox.addrow Join( trsfRow.dagta, DSep )
CRGrmCmBox.RowTag(i) = trsfRow.id
CRGrmCmBox.ListIndex = 0
GrList is currently a module. that manages its data
GrList.GrmWrdArray is a array of class RowGrmClass with dagta as the string array.
trsfRow is of the same type.
For GrList.GetRIc, GrList.GetRIc returns the element in the GrList.GrmWrdArray.
The CRGrmCmBox change event is fired only once and never enters its own code.
Can you share a simple project who demonstrate that, please ?
BTW; according to the LR, the InitialValue Property is only available at Design Time.
I can set it. I assumed, since I could set it, the LR wasn’t explaining things correctly.
Would this be a bug?
Not a bug. Because the LR is stating this clearly here: http://documentation.xojo.com/index.php/PopupMenu.InitialValue
But it would be nice if the Debugger would raise an exception in such situations.
Now i see what you mean:
Maybe a [quote]You can set a default value for the control by populating the pop-up in the Designer with Initial Values and setting the default value with ListIndex.[/quote] would be clearer.
Thanks for confirmation.
I guess I need to file some reports
[quote=404359:@Arthur Gabhart]Thanks for confirmation.
I guess I need to file some reports[/quote]
It’s not a bug.
If you are setting InitialValue and then setting rows in the Open event, the ones in the Open event are overriding what you put in InitialValue.
InitialValue is NOT the “initial selected value”, it is the data that appears in the menu of the combobox. It is the ListIndex property which determines which row out of the rows is currently “selected”.
For clarification. I don’t put anything into InitialValue in the IDE. It goes in by code.
From the LR on InitialValue:[quote]This property is only available at application design time[/quote]
The code above is what I use. Either the LR is right and I shouldn’t be able to add it, or it’s wrong.
So. Is it right or is it not necessarily set in the IDE?
Also, If I mark out my code for loading in the array but leave the LIstindex = 0, then the values I have in InitialValue are not showing as the text in the ComboBox. It is blank.
How do I get that to show?
Arthur, you can do a simple test:
- new project
- add combobox with no InitialValue set on IDE
- add Open event to combobox with
me.InitialValue = "One"
- run the code
for me the combobox is empty.
Edit: what I’m trying to say, is that you can have a ComboBox with InitialValue or not, you can delete/change whatever you need/want with code, you just can’t have an empty InitialValue and, with code, create a new InitialValue, you have to use AddRow, RemoveRow, DeleteAllRows or AddRows
I did the opposite. I eliminated the call for loading the method and I had the InitialValue set in the IDE.
This will be changed once Paul will have time to do that.
In the mean time, forget that InitialValue and use ListIndex (as always here). Then you will be able to cpntinue to develop your application (I hope so).
Emile, I think you’re confusing the purpose of InitialValue. It’s the contents of the rows of the combobox set in the IDE. ListIndex is the particular row that is selected among the rows set in InitialValue. The alternative to InitialValue would be AddRow.
The LR should be clearer. Its not that it is only available at design time, just that changing it at runtime doesnt cause any changes in the state of the control.