Jump to content
Sign in to follow this  
HeJake

GuiListViewSetColumnWidth Using $LVSCW_AUTOSIZE_USEHEADER And 300+ Columns Issue

Recommended Posts

HeJake

Hi there :)

I am encountered a problem with autosizing columns, some of the last one are getting "bugged", you can't resize them, no response (graphically) on mouse over and so on.. While the actual data are displayed correctly. It's like they doesn't fit.. but the data does  :huh:

For better explanation, try this:

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $Columns = 'Column 1|Column 2|Column 3|Column 4|Column 5|Column 6|Column 7|Column 8|Column 9|Column 10|Column 11|Column 12|Column 13|Column 14|Column 15|Column 16|Column 17|Column 18|Column 19|Column 20|Column 21|Column 22|Column 23|Column 24|Column 25|Column 26|Column 27|Column 28|Column 29|Column 30|Column 31|Column 32|Column 33|Column 34|Column 35|Column 36|Column 37|Column 38|Column 39|Column 40|Column 41|Column 42|Column 43|Column 44|Column 45|Column 46|Column 47|Column 48|Column 49|Column 50|Column 51|Column 52|Column 53|Column 54|Column 55|Column 56|Column 57|Column 58|Column 59|Column 60|Column 61|Column 62|Column 63|Column 64|Column 65|Column 66|Column 67|Column 68|Column 69|Column 70|Column 71|Column 72|Column 73|Column 74|Column 75|Column 76|Column 77|Column 78|Column 79|Column 80|Column 81|Column 82|Column 83|Column 84|Column 85|Column 86|Column 87|Column 88|Column 89|Column 90|Column 91|Column 92|Column 93|Column 94|Column 95|Column 96|Column 97|Column 98|Column 99|Column 100|Column 101|Column 102|Column 103|Column 104|Column 105|Column 106|Column 107|Column 108|Column 109|Column 110|Column 111|Column 112|Column 113|Column 114|Column 115|Column 116|Column 117|Column 118|Column 119|Column 120|Column 121|Column 122|Column 123|Column 124|Column 125|Column 126|Column 127|Column 128|Column 129|Column 130|Column 131|Column 132|Column 133|Column 134|Column 135|Column 136|Column 137|Column 138|Column 139|Column 140|Column 141|Column 142|Column 143|Column 144|Column 145|Column 146|Column 147|Column 148|Column 149|Column 150|Column 151|Column 152|Column 153|Column 154|Column 155|Column 156|Column 157|Column 158|Column 159|Column 160|Column 161|Column 162|Column 163|Column 164|Column 165|Column 166|Column 167|Column 168|Column 169|Column 170|Column 171|Column 172|Column 173|Column 174|Column 175|Column 176|Column 177|Column 178|Column 179|Column 180|Column 181|Column 182|Column 183|Column 184|Column 185|Column 186|Column 187|Column 188|Column 189|Column 190|Column 191|Column 192|Column 193|Column 194|Column 195|Column 196|Column 197|Column 198|Column 199|Column 200|Column 201|Column 202|Column 203|Column 204|Column 205|Column 206|Column 207|Column 208|Column 209|Column 210|Column 211|Column 212|Column 213|Column 214|Column 215|Column 216|Column 217|Column 218|Column 219|Column 220|Column 221|Column 222|Column 223|Column 224|Column 225|Column 226|Column 227|Column 228|Column 229|Column 230|Column 231|Column 232|Column 233|Column 234|Column 235|Column 236|Column 237|Column 238|Column 239|Column 240|Column 241|Column 242|Column 243|Column 244|Column 245|Column 246|Column 247|Column 248|Column 249|Column 250|Column 251|Column 252|Column 253|Column 254|Column 255|Column 256|Column 257|Column 258|Column 259|Column 260|Column 261|Column 262|Column 263|Column 264|Column 265|Column 266|Column 267|Column 268|Column 269|Column 270|Column 271|Column 272|Column 273|Column 274|Column 275|Column 276|Column 277|Column 278|Column 279|Column 280|Column 281|Column 282|Column 283|Column 284|Column 285|Column 286|Column 287|Column 288|Column 289|Column 290|Column 291|Column 292|Column 293|Column 294|Column 295|Column 296|Column 297|Column 298|Column 299|Column 300'
Global $Width = 800, $Height = 600

$GUI = GUICreate('', $Width, $Height, -1, -1)
$ListView = _GUICtrlListView_Create($GUI, $Columns, 1, 1, $Width-2, $Height)
_GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER))
GUISetState(@SW_SHOW)

_GUICtrlListView_BeginUpdate($ListView)
_GUICtrlListView_AddItem($ListView, '', 0)
For $i = 0 To 299
    _GUICtrlListView_AddSubItem($ListView, 0, 'Some Text To Fill Column ' & $i+1, $i)
    _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE_USEHEADER)
Next
_GUICtrlListView_EndUpdate($ListView)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    Sleep(10)
WEnd 

Any solution?  :think:

Share this post


Link to post
Share on other sites
TheSaint

That's an awful lot of columns, so I wouldn't be surprised if you were up against some sort of memory issue.

What are you using it for?

Because there might be a better way.

Perhaps embedding an Excel object ... or using two ListViews side by side, which would halve column numbers for each.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
HeJake

Well, for editing data :)

The amount of columns can be different, with those  <= 200 its okay.

Using 2 ListViews?

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $Columns = 'Column 1|Column 2|Column 3|Column 4|Column 5|Column 6|Column 7|Column 8|Column 9|Column 10|Column 11|Column 12|Column 13|Column 14|Column 15|Column 16|Column 17|Column 18|Column 19|Column 20|Column 21|Column 22|Column 23|Column 24|Column 25|Column 26|Column 27|Column 28|Column 29|Column 30|Column 31|Column 32|Column 33|Column 34|Column 35|Column 36|Column 37|Column 38|Column 39|Column 40|Column 41|Column 42|Column 43|Column 44|Column 45|Column 46|Column 47|Column 48|Column 49|Column 50|Column 51|Column 52|Column 53|Column 54|Column 55|Column 56|Column 57|Column 58|Column 59|Column 60|Column 61|Column 62|Column 63|Column 64|Column 65|Column 66|Column 67|Column 68|Column 69|Column 70|Column 71|Column 72|Column 73|Column 74|Column 75|Column 76|Column 77|Column 78|Column 79|Column 80|Column 81|Column 82|Column 83|Column 84|Column 85|Column 86|Column 87|Column 88|Column 89|Column 90|Column 91|Column 92|Column 93|Column 94|Column 95|Column 96|Column 97|Column 98|Column 99|Column 100|Column 101|Column 102|Column 103|Column 104|Column 105|Column 106|Column 107|Column 108|Column 109|Column 110|Column 111|Column 112|Column 113|Column 114|Column 115|Column 116|Column 117|Column 118|Column 119|Column 120|Column 121|Column 122|Column 123|Column 124|Column 125|Column 126|Column 127|Column 128|Column 129|Column 130|Column 131|Column 132|Column 133|Column 134|Column 135|Column 136|Column 137|Column 138|Column 139|Column 140|Column 141|Column 142|Column 143|Column 144|Column 145|Column 146|Column 147|Column 148|Column 149|Column 150'
Global $Columns2 = 'Column 151|Column 152|Column 153|Column 154|Column 155|Column 156|Column 157|Column 158|Column 159|Column 160|Column 161|Column 162|Column 163|Column 164|Column 165|Column 166|Column 167|Column 168|Column 169|Column 170|Column 171|Column 172|Column 173|Column 174|Column 175|Column 176|Column 177|Column 178|Column 179|Column 180|Column 181|Column 182|Column 183|Column 184|Column 185|Column 186|Column 187|Column 188|Column 189|Column 190|Column 191|Column 192|Column 193|Column 194|Column 195|Column 196|Column 197|Column 198|Column 199|Column 200|Column 201|Column 202|Column 203|Column 204|Column 205|Column 206|Column 207|Column 208|Column 209|Column 210|Column 211|Column 212|Column 213|Column 214|Column 215|Column 216|Column 217|Column 218|Column 219|Column 220|Column 221|Column 222|Column 223|Column 224|Column 225|Column 226|Column 227|Column 228|Column 229|Column 230|Column 231|Column 232|Column 233|Column 234|Column 235|Column 236|Column 237|Column 238|Column 239|Column 240|Column 241|Column 242|Column 243|Column 244|Column 245|Column 246|Column 247|Column 248|Column 249|Column 250|Column 251|Column 252|Column 253|Column 254|Column 255|Column 256|Column 257|Column 258|Column 259|Column 260|Column 261|Column 262|Column 263|Column 264|Column 265|Column 266|Column 267|Column 268|Column 269|Column 270|Column 271|Column 272|Column 273|Column 274|Column 275|Column 276|Column 277|Column 278|Column 279|Column 280|Column 281|Column 282|Column 283|Column 284|Column 285|Column 286|Column 287|Column 288|Column 289|Column 290|Column 291|Column 292|Column 293|Column 294|Column 295|Column 296|Column 297|Column 298|Column 299|Column 300'
Global $Width = 800, $Height = 600

$GUI = GUICreate('', $Width, $Height, -1, -1)
$ListView = _GUICtrlListView_Create($GUI, $Columns, 1, 1, ($Width-2)/2, $Height)
_GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER))
$ListView2 = _GUICtrlListView_Create($GUI, $Columns2, $Width-(($Width-2)/2), 1, ($Width-2)/2, $Height)
_GUICtrlListView_SetExtendedListViewStyle($ListView2, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER))
GUISetState(@SW_SHOW)

_GUICtrlListView_BeginUpdate($ListView)
_GUICtrlListView_BeginUpdate($ListView2)
_GUICtrlListView_AddItem($ListView, '', 0)
_GUICtrlListView_AddItem($ListView2, '', 0)
For $i = 0 To 299
    If $i <= 149 Then
        _GUICtrlListView_AddSubItem($ListView, 0, 'Some Text To Fill Column ' & $i+1, $i)
        _GUICtrlListView_SetColumnWidth($ListView, $i, $LVSCW_AUTOSIZE_USEHEADER)
    EndIf
    If $i >= 150 Then
        _GUICtrlListView_AddSubItem($ListView2, 0, 'Some Text To Fill Column ' & $i+1, $i-150)
        _GUICtrlListView_SetColumnWidth($ListView2, $i-150, $LVSCW_AUTOSIZE_USEHEADER)
    EndIf
Next
_GUICtrlListView_EndUpdate($ListView)
_GUICtrlListView_EndUpdate($ListView2)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    Sleep(10)
WEnd 

looks bad, 2 separated scroll bars, need to write additional code to control both of them using other functions and so on.. Better if there solution for such "bug"

Share this post


Link to post
Share on other sites
Yashied
TheSaint

looks bad, 2 separated scroll bars, need to write additional code to control both of them using other functions and so on.. Better if there solution for such "bug"

You should be able to NOT have one set of scroll bars displaying.

How many rows are you intending, for therein will lie the complication for two ListView matching?

I did a pretty nifty three ListBox matching in one of my programs, with the third one being the only one with a scrollbar (only vertical).

That only came about, because of things outgrowing my original vision, and way too much code to be adapted for a ListView at that point, in the amount of time I was willing to devote at that instant in time ... and later on, it became even more prohibitive to changing ... and by then, the quirk had grown on me anyway. Other parts of my program use a ListView, so it is apparent my choice was deliberate.

A ListBox is a lot less complicated though, and I don't have row limitation issues because of that.

It may not be a bug, just a limitation.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
HeJake

ListBox is not what i need. I was creating tool to simplify browsingediting, because originally it looks like:

textnumbers textnumbers and so on, up to 330(max). Easy to confuse what belongs to what. Amount of rows may be up to 2000, but thats not a problem, it loads okay (slow tho). The problem is only autosizing columns (headers), i could use just 

$LVSCW_AUTOSIZE, but wanted to make it look clear.

Share this post


Link to post
Share on other sites
TheSaint

I wasn't suggesting a ListBox replacement, only a similar approach for two ListViews.

You may just be better off embedding an Excel object, for which I'm sure you will find help here.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×