Hi
I’ve got several listbox columns formatted as CheckBoxes, they work great with the exception that each CheckBox column as well as showing the CheckBox, also shows the value from the database, ie: TRUE or FALSE, which is unnecessary and looks messy.
Is there any way to have it only show the CheckBox?
I know there are ways around it, but before I code some sort of messy workaround I wondered if there is something I’m missing?
As far as I know, there is nothing in the listbox that adds the words “true” or “false” by default when you set the CellType to a checkbox. Are you sure you don’t have anything in your PaintCellText event adding that yourself?
Hi, thanks for the reply. No nothing in the paint.
The value displayed is the actual text value from from the listbox cell, so defining the column as a checkbox does just that, it unfortunately puts the text value of the cell next to the checkbox! Weird
I am not able to replicate this behavior, even when switching to API 1.
In Xojo, when a boolean value is converted to a string, the case it uses is “True” and “False” and not all caps as depicted in your listbox. This may indicate that it’s your code somewhere that’s adding this text from the database.
Hi
Yes, the value in the database is TRUE or FALSE in that column, its a Text value, the database is SQLITE and the database is syncronised with a SQLServer database which is how the columns are defined in the commercial program that I’m syncronising with.
I guess I initially thought by defining them as checkbox values in the listbox it would interpret the values of TRUE of FALSE correctly, but as it didn’t I have tried changing them to values that would convert to checkbox values, such as True, False, Y or N, however whatever I change them to I have to set the checkbox states manually (which is fine) I just wish I could get them to not show the actual values. I suppose I could try setting the listbox values to blank after I’ve processed the list and set the checkbox states. Just seems like it shouldnt be that long winded? Never mind, thanks for your help anyway
Just to be sure (and I hope this is still the case with API 2): you do not care about what is written in the db file.
You use a boolean (what the CheckBox gaves you) to save the CheckBox state (value) at write time, and at read time, you read a Boolean and set that to a Boolean value, then set the CheckBox with that Boolean value.
Is it clear now ?
In the LR, check SQLiteDatabase
and go directly at the FieldType definition:
This table identifies the Column Type based on the FieldType
Hi
Yes, it’s clear, however for reasons to do with ease of syncronisation I want to use the column types as defined by the commercial product, hence not using booleans.
I was expecting (wrongly) that if I defined a listbox column as a checkbox then that is what I would see, and only that, leaving me to decide the state of the checkbox whether the underlying columns was string, boolean, integer. IMO the listbox controls should be independent of the underlying data, but maybe even make it more straightforward by attempting to map the underlying data source in a logical fashion. It doesn’t matter however I’ve just blanked the values in the listbox after I’ve set the checkbox states, it just seems a bit messy, but it works so all ends well
On a side note I have never used boolean in a database. Oracle (which I’m most familiar with) doesn’t (didn’t) have a Boolean column type, although apparently it does now, and in SQLServer it also doesn’t have a boolean type, although I would use a BIT type if I were doing it in SQLServer as it serves the same purpose. sigh there must be simpler ways to make a living lol
It could be worse though, sometimes I have to fix legacy code written is C# or VB.NET or even worse Omnis7 …
I am curious to know how you assign numbers (Integers, Floats) to a ListBox…
At Database TABLE definition (SQLite), you define Column(s)/Column(s) Types: that is here that you says you want a Column of type Boolean.
At Read Time, you ask for Record sets, then you read all Columns from one Record set; it can be …String, .Integer, .Boolean…
Storing the Boolean you get from the Record into a Boolean variable allows tou to set the CheckBox Value (in an If Block to be sure).
Something like
If wasContacted Then
// Set the CheckBox to .Checked
Else
// Set the CheckBox to .Unchecked
// If this .Unchecked is the correct command
End If
There is no need to set a string holding “TRUE” or “FALSE” to the ListBox, then check in an If block and set the CheckBox accordingly.
Now, if you are happy with what you have now, I have nothing more to say.
(unless if one day SQLite change “TRUE” to “True” or “true” and start to be case sensitive… (for examples).
Hi
Agree. However as I said I don’t have control of the underlying database column types and if I did I wouldn’t use a Boolean for the reasons stated earlier.
So as a solution, after the list is built, I ctcle throug it and I read the string “TRUE” for example from listbox.cell(i,X) then set that cell to be a checkbox with the value checked, then set the column value to blank so that no actual values appear.
If I were reading from the database in a listbox I could do all this at that point, but I have a central procedure that executes the sql and populates the passed listbox for me so I have no manual involvement, this saves a ton of time with the downside that occassionally I have to do some modifications after the list is built. Like in this case
Hi Beatrix
The values come directly from the database in a listbox. They are Text columns and have the values TRUE or FALSE.
Thanks, it’s sorted now anyway I just wondered if there was a property on listbox checkboxes to hide or show the underlying data.
Cheers - Steve
Hi Emile
Yes and if I was manually building the listbox I could use those, but as the listbox size, structure and content are generated by a single call to the database any changes to the listbox have to be done later, which is what I ended up doing.
Cheers
S
What is the purpose of the SQLite database? I would have expected to load the Listbox from the actual database which upthread I think you said is SQL Server.
Lol, true, I used it from Omnis 5 on an Apple 3?, through Quartz on Windows 3.11? until 2007 on Windows XP or 7 I can’t remember. Xojo was the ‘spiritual successor’ of Omnis to me, but when I go back to it now … it’s horrendous, it was great in its day though