First of all, I check if there is a Heading for the target ListBox,
Then I check InitialValue (empty or not),
and then what can I do to determine if the ListBox Heading is empty ?
First of all, I check if there is a Heading for the target ListBox,
Then I check InitialValue (empty or not),
and then what can I do to determine if the ListBox Heading is empty ?
ListBox.Heading is a property (actually it is a method not a property) which is read-write. See here ListBox.Heading
You should be able to do this:
Dim isEmpty As Boolean = ( lbx.Heading(-1).Trim = "" ) // if true all headings are empty
// Or
Dim isEmpty As Boolean = ( lbx.Heading(1).Trim = "" ) // if true all heading of column 1 is empty
Hi Eli,
there are no space(s) in the Heading when it is empty. I tried [excepted if you put some ;-:)]
If lbx.Heading(-1) = "" Then
but this does not worked. Thus my question.
I acutally use:
If lbx.Heading(0) = "" Then
But I think this is (may be) error prone.
A heading needs a space to be empty. If a Heading is “”, then Xojo automatically replaces it with “Column xxx”. So to have an empty heading you must assign a space.
Back to roots.
When you do not put anything in a Heading, it is what I called Empty (but a number id displayed).
It happens to me to put a space int the Headings when the window opens and the user needs to load something in the ListBox: I do not want to display “0”, “1”, etc. I consider that as a non Empty Heading.
The question remains:
How can I know if / when the Heading have its default value ?
Heading will return the columnNumber:
Dim isColumn0Empty As Boolean = ( lbx.Heading(0).Trim = Str(0) )
Eli,
thank you for your kind answer.
I confirm. For a ListBox with one Column, I get “0” (code below)
MsgBox "Contenu de LB.Heading" + EndOfLine + EndOfLine +_
LB_One.Heading(-1)
If the Heading is filled with data, I will get the data for each Column and a Chr(9) as Column delimiter(s).
So, I may have to build my own default value. I built the code below for a specific (4) number of Columns:
If LB.HasHeading And LB.Heading(-1) <> "0" + Chr(9) + "1" + Chr(9) + "2" + Chr(9) + "3" Then
And this works fine.
Now, I only have to add code to build the “real string” to compare with LB.Heading(-1) <>
depending on the number of current columns and I will be done with that feature.