Sign in to follow this  
Followers 0
Der_Andi

List view column does not stay hidden

7 posts in this topic

Hi all,

I've got a listview with three columns. The first two columns have a width of 0, so they are hidden. But when I add new items, the second column gets visible. The first column stays hidden.

How can I prevent the second column from getting visible? Just setting it to 0 again seems to be not right for me.

Here's an example, demonstrating the problem:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

GUICreate("", 400, 300)
$hListView = GUICtrlCreateListView("||items", 2, 2, 394, 268)

_GUICtrlListView_SetColumnWidth($hListView, 0, 0)
_GUICtrlListView_SetColumnWidth($hListView, 1, 0)

GUICtrlCreateListViewItem("hidden|hidden|visible", $hListView)
GUICtrlCreateListViewItem("hidden|hidden|visible", $hListView)
GUICtrlCreateListViewItem("hidden|hidden|visible", $hListView)

GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites



Der_Andi,

I am afraid I have not come up with anything better than rehiding the column each time you add an item. :)

Why do you want to have the first 2 columns hidden? Perhaps there is another way to do this. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Don't mix the native AutoIt GUI functions with the UDF functions if you can help it. It works fine if you use the UDF throughout:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

$hGUI = GUICreate("", 400, 300)
$hListView = _GUICtrlListView_Create($hGUI, "hidden|hidden|visible", 10, 10, 380, 280)

_GUICtrlListView_SetColumnWidth($hListView, 0, 0)
_GUICtrlListView_SetColumnWidth($hListView, 1, 0)

For $n = 0 To 3
    _GUICtrlListView_AddItem($hListView, $n & "-0 hidden")
    _GUICtrlListView_AddSubItem($hListView, $n, $n & "-1 hidden", 1)
    _GUICtrlListView_AddSubItem($hListView, $n, $n & "-2 visible", 2)
Next

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Interesting!

I didn't know that mixing native functions with UDF's can have such negative effects. I've been doing this ever since and everything worked out so far. ;)

Thanks for the tip, PSalty.

@Melba:

I hope, it is okay with you, if I just use this solution. It would have been quite a story just to cover the basics of my program ;-)

Share this post


Link to post
Share on other sites

Der_Andi,

Of course! :)

I was just looking for an alternative solution, but our resident waterfowl has come up with one for us. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I'd like to add, that there is indeed a way, how you can mix native GUI functions with UDF's. When using UDF's, make sure you use the handle of the control. Then it works, too. Or in my case: column widths do not change.

Creating listviews with _GUICtrlListView_Create() has one drawback: they are not affected by GUISetFont.

So I found the clue in this thread: http://www.autoitscript.com/forum/index.php?showtopic=70077&view=findpost&p=513807

Edited by Der_Andi

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  
Followers 0