Press header without showing sort arrow ?

Hey forum…
I guess the subject says it all.

I searched the forum but I can not get the listbox headers to be selected without the arrows.

Either they don’t get selected at all (with tthis code in header presssed event)

me.SortedColumn = -1 //----- remove sort arrows step 1
me.HasHeading = False //----- remove sort arrows step 2
me.HasHeading = True //----- remove sort arrows step 3

or they get selected and show the arrows.

What I actually want to do is just highlight a column… how do I achieve it ?

thaaanks!
Roman

The arrows are part of the sort highlight.
Listboxes aren’t system native controls, so I don’t even think there’s declares to hide them.

On Yosemite and El Capitan there is no other indication a column is selected other than those arrows, so I’m not sure that will work out well either.

Could you explain why you want to show a column is sorted without the directional? From a UX standpoint I can’t understand why you wouldn’t want to show them.

Hey Tim, thnx for the reply…

Actually I DO NOT WANT to sort the column… just want to slect it, and highlight it… I am now writing code to paint (on the cellbackgroundpaint) the sides of each cell of the “selected” column to simulate a selected status on the column of the listbox.

But I would really like that only to be shown on the header as the listbox is full of colored information, and painting the sides of each cell will only add more information to an already clutterred listbox…

I’m not exactly sure what you mean.

I don’t think you can have the sort option without the arrows by default. If you want that, you need to handle the sorts yourself.

To turn off the the sorting (and therefore turning off the arrows) put this in the open event:

Me.HeaderType(-1) = Listbox.HeaderTypes.NotSortable

If you want to get the clicked column index, you can do something like this in the mousedown event:

Dim columnIdx As Integer = Me.ColumnFromXY(x, y + Me.HeaderHeight)

As for highlighting the selected column, maybe you can paint the cell colors.

Another option is making your own custom header from a canvas.

maybe this picture will help me express my point… The headrs are the dates…

Here’s what I achieved so far…

http://s16.postimg.org/r6tqbf7z9/Clipboard_1.png

I would like to somehow highlight one the headers, (the one representing ‘today’)

I would not use a list box at all :stuck_out_tongue:
A custom canvas subclass and draw it however you want, make it respond however you want
Why ?
Well if those are “dates” in the columns the listbox is going to have an issue with more than 64 date headers (despite the fact it can show up to 256 columns)
But a custom canvas can do whatever - but it IS more work

And just FYI the old editor in the IDE itself was - just a canvas - a very customized one - but still JUST a canvas

Thanks Norman… Intresting…

I think your suggestion would be more work… keep in mind that the listbox never has more than 13 columns. (12 dates, plus the first non date column), so I will never have to deal with the limitation you mention.

The listbox has a scrolling effect… and loads up dynamically the data corresponding to the shown dates, and of course re draws the info as you click (go) forward or back in the timeline …

Anyway… I guess it is not possible to just “select” a header without displaying the arrows ?

How about just lighting the cells of the column when you click on a header? That you can make the Listbox relatively easily do without showing the sort arrows

  • Karen

Hey Karen… this is what I am thinking I should do… the cells already may contain colored backround+colored text+some black lines , so “lighting” them may have it’s difficulty… I don’t know…

I wil try just adding up a value to all the colors chosen for the elements in the cell… Not sure I am thinking this straight… it’s late here…
thanks a lot

Overlay a canvas on top of the listbox and draw the outline into it.

You can also simply replace the header altogether and do whatever you want with it to indicate selection.

Dave S has one for Mac here http://www.rdS.com/listbox_header.dmg

cool! Thanks for the ideas !