Ah, the unbearable agony of seeing all those Xojo goodies and not knowing when to use them and where in the code to put them!
I have a two-column listbox, where the first column contains field labels and the second column contains the field values.
I want to make the field labels less conspicuous or alternatively the field values more prominent. The labels and the values are in their arrays for each row. How may I code this?
ChatGPT advises to use the CellTextPaint event handler for listbox, but I can’t find it there.
Thank you very much in advance
The event is now called PaintCellText, but it pretty much operates the same. It allows you to treat the cell like a canvas. Yet another of ChatGPT getting it wrong. Take everything it says with a grain of salt. It may point you in the right direction, but you have to know enough to dig up the right answer.
chatgpt seems to know little about api2, especially the control items (which changed recently with desktopcontrols). may be the paid chatgpt 4 knows better but I’m not sure as I don’t pay for it
Since it cost over a billion dollars to train ChatGPT last time, I don’t know how much of a priority Xojo will be next time.
Gtp4 is trained with info until 2023 april i believe.
So api 2 should be part of it. I can say it does a pretty good job for a human helper
ChatGPT is very good with the logic, not so good with the syntax.
When in doubt, paste in the documentation for the pertinent xojo class prior to asking it for code. Be specific about your desired inputs and outputs, and make sure to tell it you’re using Xojo API 2.0. When referring to controls, refer to their 2.0 names like DesktopListBox instead of Listbox.
When giving ChatGPT (the paid, GPT-4 version) the proper prompts, it’s generated very good Xojo code for me.
As @Tim_Hare wrote, in this case it’s recommended to use the PaintCellText (Documentation) Event.
Within this Event you have local Variables for the row, column, x and y axis and more.
Just make sure you are in the correct row/colum and then use the local Graphics (g) Object, which represents the Cell Canvas, to draw your Text.
If column = 0 Then
g.FontSize = 10
g.Bold = True
g.DrawingColor = &cD6D4D600
Return True // Tell Xojo that drawing the Text has been done already by returning True
In this example i took the CellText and wrote it using the above Parameters. If you then RETURN TRUE from this Event, Xojo won’t “write” the Text within this Cell again.