WebListBox.ColumnWidths

Does anyone know the reason why it doesn’t work in the WEB 2020 version, the size of the columns?

Me.ColumnCount = 2
Me.ColumnWidths = “100,100”

The Opening event handler can be used to initialize non-visual properties and settings for controls. In most cases, you should use the Shown event to initialize controls.

The property ColumnWidths does not work when it is called from Opening. Works if it is done in the Shown event.

This isn’t supposed to be true in 2020r1. Please file a bug report with a sample so we can get this cleared up for this control.

Edited to follow OP code.

This is how the weblistbox looks when that code is in the opening event:
image

This is how it looks in the Shown event:
image

I don’t understand why you say that it works by putting the code in the shown event because the width is not set at 100 pixels either way.

This has nothing to do with the original topic. Please don’t hijack the thread.

From https://documentation.xojo.com/api/user_interface/web/webcontrol.html#webcontrol-opening

The control has been created and the page is opening but has not been sent to the browser yet.

Notes

The Opening event handler can be used to initialize non-visual properties and settings for controls.

In most cases, you should use the Shown event to initialize controls.


Jose did a copy/paste from that docs page.

Edited my previous post to show how the WebListbox looks using that code in the Opening event and in the Shown event. I hope that has something to do with the original post.

Thanks, Greg.

Alberto, I made the test with data (sometimes the length repeated itself). I made double sure that I didn’t mess up, and if you leave the code in the Opening event with ColumnWidths, it does not work.

The same happens with HeaderAt in the Show event.

Try doing the test yourself, fill 3 columns with different sizes, and different head names. Fill them up with data that ranges from 5 to 10 rows.

Maybe, I am doing something wrong.

Sorry, I don’t fully understand your problem and it looks like I’m seeing other problems too. Can you create a sample and share it?

@AlbertoD @Jose_Fernandez_del_Valle

Here is a visual summary capturing some (but not all) of the issues you maybe experiencing. It might assist your feedback case.

Kind regards, Andrew

While this controls shouldn’t appear, the listbox always uses RowSets behind the scenes because we create an in-memory sqlite database to manage the data.

Thank you for clarifying that point @Greg_O_Lone. At what point, should those controls appear (greater than 25 rows if adding rows with AddRow)?

They shouldn’t appear at all in the config we are using because they cause issues with positioning and we aren’t using pagination.

1 Like

Thanks, Andrew.

That is what happens to me, I fixed it by adding the code where it works.

In your example, ColumnWidths is always ignored. On my end, one ColumnWidth works and the other does not.

Thanks to you, I am a step closer to migrating from XOJO 2019 to XOJO 2020.

1 Like

I’m running Xojo 2020R2, and the following code in Opening or Shown of a WebListBox does not change the column widths:

Me.ColumnCount = 5
Me.ColumnWidths = “100, 200, 50, 100, *”

If I run the code in the Shown event, I get the “Show X entries” and “Previous / Next” buttons as shown in Andrew’s post.

Is there a workaround as I need to set the number of columns and their widths dynamically?

1 Like

Try this code:

In WebListBox SHOWN event:
Me.ColumnWidths = “100, 200, 50, 100, 20”

In WebListBox OPENING event:
Me.ColumnSortTypeAt(0) = WebListBox.SortTypes.Unsortable
Me.HeaderAt(0) = “Any Name”

Tell me if it worked for you.
In my experience, only dynamic change works on a SHOWN event.

No, that didn’t work.

Did you actually got this to work so you could set the column widths?

Not really. Try to add only one character (at least less than your column is defining), then it will work, but if you are adding then more text it might very well overrule your settings. In other words: it works for me for columns with a fixed number of characters (dates etc), but if I can’t predict the length of the content, I usually run into trouble. Can you confirm this by trying it yourself?

Here is my summary of issues with the WebListBox 2.0:

  1. You cannot Select Rows in code (<https://xojo.com/issue/60041>)
  2. ColumnWidths cannot exceed 100% (<https://xojo.com/issue/61610>)
  3. ColumnCount cannot be changed in Code (<https://xojo.com/issue/61631>)
  4. WebListBox doesn’t centre on the WebPage like other objects (<https://xojo.com/issue/61837>)
  5. You cannot force a WebListBox to hold all the data (<https://xojo.com/issue/61765>)
  6. You cannot Add Rows, Remove Rows in one Method, then use RowCount as it will be inaccurate (<https://xojo.com/issue/62633>)
  7. If you double-click a selected Row, no Row is selected in the DoublePressed Event (<https://xojo.com/issue/62779>)
  8. WebListbox on a WebContainer on a WebTabPanel shows Rows differently (<https://xojo.com/issue/62823>)
  9. Unlike Desktop, WebListBox has no LastRowIndex (<https://xojo.com/issue/62749>)
  10. WebListBoxes don’t draw when moving amongst WebPagePanels (<https://xojo.com/issue/62821>)
  11. WebListBox Heading text wrapping causes WebListBox to become taller (<https://xojo.com/issue/62827>)
  12. WebListbox.CellAt doesn’t function after WebListBox has been sorted (<https://xojo.com/issue/62772>)
5 Likes

Plus, the text within WebListBox cells do not wrap — the WebListBox shrinks until the text fits on one line, then will shrink no more.

Thank you David, even though it’s i bit depressing.

Issue 1, 2 and 3 in your list prevent me from upgrading my apps to web 2.0.

With your list I know which issues I should wait for.