Jump to content

Recommended Posts

Posted

Hi everybody :)
Concerning listview controls, I thought that it was possible to insert a column 0 at the very left side of the listview.
Unfortunately the following script shows that it's not possible.

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

Example()

Func Example()
    GUICreate("Insert col 0", 280, 180)

    Local $idListview = GUICtrlCreateListView("Col 1 |Col 2 |Col 3 ", 30, 25, 215, 100)
    Local $idItem1 = GUICtrlCreateListViewItem("cell-1a|cell-2a|cell-3a", $idListview)
    Local $idItem2 = GUICtrlCreateListViewItem("cell-1b|cell-2b|cell-3b", $idListview)
    Local $idItem3 = GUICtrlCreateListViewItem("cell-1c|cell-2c|cell-3c", $idListview)
    Local $idButton = GUICtrlCreateButton("Insert col 0", 100, 140, 70, 20)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idButton
                _GUICtrlListView_InsertColumn($idListview, 0, "Col 0")
                GUICtrlSetState($idButton, $GUI_DISABLE)                
        EndSwitch
    WEnd
EndFunc   ;==>Example

1003252193_InsertCol0.png.1cf4e6e4d43cfe61841bcf0077571322.png

That's (probably) what means the sentence found in the help file, topic GUICtrlListView_InsertColumn :
"The alignment of the leftmost column is always left-justified; it cannot be changed"

But well... "left-justified" usually means : "to align text along the left margin"
Using terms like "alignment" and "left justify" seems a bit confusing in this case as we're not talking about text, so if there's no other of way to do it natively, I'll insert a column having an index equal to 1, then drag its header at the very left.

Is it the recommended way to insert an empty column at the very left ?
Thanks

"I think you are searching a bug where there is no bug..."

Posted
23 minutes ago, Danp2 said:

This is what I get when I run your code

I get the same result (AutoIt 3.3.14.0). With $iIndex>0 it works as expected.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted (edited)

Thanks for your both answers :)
I'm using Autoit last official version 3.3.14.5

@Danp2 : the result in your image looks even worse than mine, as all your headers are shifted and don't correspond to the original columns anymore. As you wrote :

3 hours ago, Danp2 said:

it's like a column header was inserted at the designated spot.

But it's not what the script is intended to do as we wanted a blank column to be inserted at the left side of the listview control. Here are a couple of other tests I just did :

* These 2 lines are equivalent and give same correct result :

_GUICtrlListView_AddColumn($idListview, "Col 4")
_GUICtrlListView_InsertColumn($idListview, 3, "Col 4")

870548176_AddCol.png.b650033789bba0af0c313e976d03adec.png

* And this one is ok too :

_GUICtrlListView_InsertColumn($idListview, 1, "Col 1x")

21264625_InsertCol1x.png.29bc3ee5adce8dcdad8298ccdbfd688b.png

It seems like we shouldn't mess with column 0 and never use _GUICtrlListView_InsertColumn($idListview, 0, ...) when the lisview has already been populated.

As I wrote in the 1st post, inserting "Col 1x" (as in the pic just above) then dragging its header to the very left will do the job : a blank column will be added at the left side.

OK, I'll have a quick look at Microsoft forums to see if anyone faced the same initial issue and let you know.

Edited by pixelsearch

"I think you are searching a bug where there is no bug..."

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...