New DesktopLisbox

I’m having difficulties porting old code to new API.
Foe example my original ListBox had the following:

me.GridLinesHorizontalStyle = ListBox.Borders.ThinDotted

Going to DesktopListBox help you get this
image

There’re not examples.
if you type
me.GridLineStyle = DesktopListBox.GridLineStyles… you get four options:

image

There is not dotted option

I assume in some place should be an explanation but I found difficult to found the equivalencies and a better help to port objects to API 2.
A, for example," this is obsolete you should use xxxx"

Looks like they scrapped the “dotted” possibilities.

What you have now are separators which are pale gray lines - looks much better IMO.

They do that with standard API Xojo 2021…

I do not like that.

1 Like

In the Language reference a property of the new DeskTopListbox is:
DesktopListBox.GridLines
but the compiler;

Window1.ListBox1.Opening, line 1
Type "DesktopListBox" has no member named "GridLines"
me.GridLines =  DesktopListBox.GridLineStyles.Horizontal

If you look at Enumeration in DesktopListbox you see:

[DesktopListBox](https://documentation.xojo.com/api/user_interface/desktop/desktoplistbox.html).**GridLineStyles**

But
Window1.ListBox1.Opening, line 3
Type "DesktopListBox" has no member named "GridLineStyles"
me.GridLineStyles = DesktopListBox.GridLineStyles.Horizontal

The only thing it works is

me.GridLineStyle = DesktopListBox.GridLineStyles.Horizontal

That is not documented …, it’s me? Or …

If that’s a bug then report it. Me, I do all my listboxes’ gridlines in the IDE.

I took a quick look at the docs. Apparently there is no longer a way to set the individual borders of the listbox sides… that is something I have used extensively in UIs for various purposes over the years…

If that capability is truly gone, and the only option is then to draw the borders yourself in cell background paint it is a huge lose of “RADness” for those who bothered to truly learn what the API 1 listbox was capable of, and who have used it’s capabilities to the fullest.

How long can we expect the original API 1 controls to be supported?

-karen

A word of caution when looking at documentation with the new DesktopListBox. When this control is shown as an example for other controls, a number of those examples do not show the new control, they have the deprecated control and old attributes. I have been reporting them to the powers that be, but just be aware.

You could use the paint event for the cells by row, and draw a dotted line across the bottom of each row? Then, you not only get to choose the ‘harshness’ of the dotted or dashed line, but can also choose thickness and customize stylization far beyond what the ancient dotted property offers. :slight_smile:

There’s a menu option to “update all controls to API 2.0.” It’s good learning practice to convert the few controls. There’s far much more code available that you’ll have to convert at some point or another, than not. Unless you exclusively use paid controls, that is.

That is obviously possible … BUT it is also a lot more time consuming.

For or most (but not all) uses , the ancient CellBorder methods.settings are “good enough”… though it would have been nice if they had added setting color as an option to those…

Oh well.

-Karen

what is the point of upgrading a control when it looses the functionality it had. Upgrade means more functions and stability. If everything should be done by code then what is the purpose of a RAD system.

2 Likes

Most of the time, people do that to remove a bug while removing a feature (instead of only removing a bug).

Nota: I do not know if this is the case for this feature.

I believe it’s for Windows 11 and the likes that no longer have “dotted” as a native option in newer Windows APIs, due to a change made by Microsoft. At least Xojo affords you the opportunity to still paint it yourself if you wish. In essence, that’s all that’s happening under the hood anyway :slight_smile: Microsoft probably figured it’s just code bloat since it’s not really used now-a-days. The Linux kernel is under a code bloat purge also.

But isn’t the Listbox a Xojo custom control and not native?

1 Like

It’s a native control under the hood :slight_smile:

1 Like

It’s not that dotted was removed so much (being able to set color is better looking, and that with setting thickness would be enough) but that the ability to set the individual cell borders was removed…

I have a lot of UI that NEEDs those to be set individually to make it more easily comprehensible (user friendly) and it would take a LOT of time to rewrite that using cellbackround paint.

If I was unemployed I would write a (actually add to an existing) Listbox Subclass to create a general use API for that…but I am employed so don’t have the time…

I know from experience such things are a lot more work than it seems they should be. to get it to aways look right X-Platform combined all the other listbox settings that are possible.

I pay for Xojo for them to do that kind of stuff…

-karen

:grinning: ah ok just wanting to make sure

If you use software like Spy++ that comes with visual studio, you can hook into your window class and review the native underlying controls, as well as their behavior.

1 Like

It really takes no time to do. See attached demo. It just took me all but 3-4 minutes to throw together a sub-classed re-usable control. You can turn vertical & horizontal dashed lines on or off and change the dash color. If you use the PaintCellBackground event, your painting will paint behind the dashed lines. :slight_smile:

Hope the code helps you get inspired!

**If you use the control in an existing project, you can simply change the Super of existing listboxes to adopt the dashed-line features.

1 Like

We will have to agree to disagree…

Quick and dirty or for one specific of type of listbox usage is always easy…

I’m the one who wrote the mergeable cell listbox class where you could merge cells across rows and columns… so I think I have a decent idea of what’s involved in creating an API that meshes with ALL the listbox features transparently X-Platform…

-Karen

1 Like