pixelsearch Posted December 30, 2019 Posted December 30, 2019 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 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..."
Danp2 Posted December 30, 2019 Posted December 30, 2019 What version of Autoit are you using? This is what I get when I run your code -- For me, it's like a column header was inserted at the designated spot. Latest Webdriver UDF Release Webdriver Wiki FAQs
Musashi Posted December 30, 2019 Posted December 30, 2019 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. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
pixelsearch Posted December 30, 2019 Author Posted December 30, 2019 (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") * And this one is ok too : _GUICtrlListView_InsertColumn($idListview, 1, "Col 1x") 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 December 30, 2019 by pixelsearch "I think you are searching a bug where there is no bug..."
Professor_Bernd Posted January 4, 2020 Posted January 4, 2020 Hello. This is probably because a ListView consists of Items (first row left) and these Items have SubItems (all other rows). The (Main-)Item is the root of each row. Maybe this is why it cannot be moved. Bernd. Musashi and pixelsearch 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now