Jump to content
Valnurat

A little advice

Recommended Posts

Valnurat

What kind og GUI item can I use to show some numbers in?

I would like to have the option not to have scrollbars and if possible have 3 columns and it sould also have the option to sort the content.

What would you suggest?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Melba23

Valnurat,

I would suggest a ListView.

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
Valnurat

Ok, but it dosen't seem that I have any option to not have any scrollbars.


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Melba23

Valnurat,

You only get scrollbars if there are too many items to fit into the control - and if you did not have the scrollbars you would not be able to see the items. Why is this such a breaking point?

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
Valnurat

That's true, but in my situation it is not necessary to see them all. Only the top 20 numbers.

Can you change the size of the font in the ListView?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Melba23

Valnurat,

Quote

Can you change the size of the font in the ListView?

Yes, if you create the ListView with GUICtrlCreateListView then GUICtrlSetFont will work.

And if you only want the top 20, then only load that many into the ListView - that way you will avoid scrollbars if you size the control correctly:

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>

$hGUI = GUICreate("Test", 500, 500)

$cLV = GUICtrlCreateListView("Col 0|Col 1|Col 2", 10, 10, 480, 480)

; Size columns
For $i = 0 To 2
    _GUICtrlListView_SetColumnWidth($cLV, $i, Int(480 / 3) - 2) ; avoid horizontal scrollbar by makign columns slightly smaller then total width
Next

; Fill ListView with 20 items
For $i = 0 To 19
    GUICtrlCreateListViewItem(StringFormat("%05i", $i) & "|" & StringFormat("%05i", $i) & "|" & StringFormat("%05i", $i), $cLV)
Next

; Now size ListView vertically
$hHeader = _GUICtrlListView_GetHeader($cLV)
$aSize = WinGetPos($hHeader)
$iHeaderHeight = $aSize[3] ; Header height
$aRect = _GUICtrlListView_GetItemRect($cLV, 0)
$iItemHeight = $aRect[3] - $aRect[1] ; Item height
$iTotalHeight = $iHeaderHeight + (20 * ($iItemHeight + .5)) ; Allow for the inter-item gaps
; Resize ListView
GuiCtrlSetPos($cLV, 10, 10, 480, $iTotalHeight)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

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
Valnurat

Thank you M23.

I need to have 3 listview in my project.

1. To have a listview1 with 3 columns with vertical lines to seperate the columns and in designtime have vertical scrollbars and no horizontial. I want to know from the start, how it would look like when numbers are added.

2. To have another listview2 that only show the top 20 numbers out of 90 and when numbers are picked out from LV2 it should be transferred to listview3 and then the next number should be visible. E.g. In your example 0-19 are visible. If 7 is picked, it should still show the top 20 numbers in LV2 and 7 is moved to LV3.

For now it seems that the listview only show scrollbars if it is necessary. Or do you have another suggestion?

Edited by Valnurat

Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Melba23

Valnurat,

How about this:

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>

$iMax = 90

Global $aMainArray[$iMax]
For $i = 0 To $iMax - 1
    $aMainArray[$i] = StringFormat("%05i", $i) & "|" & StringFormat("%05i", $i) & "|" & StringFormat("%05i", $i)
Next

$hGUI = GUICreate("Test", 900, 500)

; Create ListView 1
$cLV_1 = GUICtrlCreateListView("Col 0|Col 1|Col 2", 10, 10, 280, 480)
; Size columns
For $i = 0 To 2
    _GUICtrlListView_SetColumnWidth($cLV_1, $i, Int(280 / 3) - 2) ; avoid horizontal scrollbar by making columns slightly smaller then total width
Next

; Fill ListView with all items
For $i = 0 To $iMax - 1
    GUICtrlCreateListViewItem($aMainArray[$i], $cLV_1)
Next

; Now calculate ListView 2 vertical size
$hHeader = _GUICtrlListView_GetHeader($cLV_1)
$aSize = WinGetPos($hHeader)
$iHeaderHeight = $aSize[3] ; Header height
$aRect = _GUICtrlListView_GetItemRect($cLV_1, 0)
$iItemHeight = $aRect[3] - $aRect[1] ; Item height
$iTotalHeight = $iHeaderHeight + (20 * ($iItemHeight + .5)) ; Allow for the inter-item gaps

; Create ListView 2
$cLV_2 = GUICtrlCreateListView("Col 0|Col 1|Col 2", 300, 10, 280, $iTotalHeight)
For $i = 0 To 2
    _GUICtrlListView_SetColumnWidth($cLV_2, $i, Int(280 / 3) - 2)
Next
; Fill with top 20 of array
For $i = 0 To 19
    GUICtrlCreateListViewItem($aMainArray[$i], $cLV_2)
Next

; Create button to move element from ListView 2 to ListView 3
$cMove = GUICtrlCreateButton("Move Selected", 300, 430, 280, 60)

; Create ListView 3
$cLV_3 = GUICtrlCreateListView("Col 0|Col 1|Col 2", 600, 10, 280, 480)
; Size columns
For $i = 0 To 2
    _GUICtrlListView_SetColumnWidth($cLV_3, $i, Int(280 / 3) - 2)
Next

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cMove
            $sText = _GUICtrlListView_GetItemTextString($cLV_2)
            If $sText Then
                ; Add to ListView 3
                GUICtrlCreateListViewItem($sText, $cLV_3)
            EndIf
            ; Find element in main array
            $iIndex = _ArraySearch($aMainArray, $sText)
            If $iIndex <> - 1 Then
                ; Delete it
                _ArrayDelete($aMainArray, $iIndex)
            EndIf
            ; Now clear ListViews 1 & 2
            _GUICtrlListView_BeginUpdate($cLV_1)
            _GUICtrlListView_BeginUpdate($cLV_2)
            _GUICtrlListView_DeleteAllItems($cLV_1)
            _GUICtrlListView_DeleteAllItems($cLV_2)
            ; And reload with all / the top 20 elements in the main array
            $iMax = UBound($aMainArray) - 1
            For $i = 0 To $iMax
                GUICtrlCreateListViewItem($aMainArray[$i], $cLV_1)
                If $i < 20 Then
                    GUICtrlCreateListViewItem($aMainArray[$i], $cLV_2)
                EndIf
            Next
            _GUICtrlListView_EndUpdate($cLV_1)
            _GUICtrlListView_EndUpdate($cLV_2)
    EndSwitch
WEnd

That seems to do what you require.

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
Valnurat

That is awesome.

Is it possible to have vertical lines between the column all the way down in listview 1 and can you sort listview 3?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Valnurat

Listview1 should have 3 columns, Listview 2 and 3 should only have 1 column.

And it could be nice if there was no header in the listviews.

Edited by Valnurat

Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
Melba23

Valnurat,

12 hours ago, Valnurat said:

Is it possible to have vertical lines between the column all the way down in listview 1

You can apply the $LVS_EX_GRIDLINES style, but that gives you vertical and horizontal lines.

12 hours ago, Valnurat said:

can you sort listview 3?

Yes, the _GUICtrlListView_SimpleSort example in the Help file shows you how to do it.

1 hour ago, Valnurat said:

Listview1 should have 3 columns, Listview 2 and 3 should only have 1 column

Then amend the code used when you create the ListViews 2 & 3.

1 hour ago, Valnurat said:

And it could be nice if there was no header in the listviews.

Just apply the $LVS_NOCOLUMNHEADER style.

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
Valnurat

Thank you very much. 5 stars.

I learn a lot from your example.


Yours sincerely

Kenneth.

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

  • Similar Content

    • ohaya
      By ohaya
      Hi,
      I have a situation where I need to make one request to get a kind of pre-logon page, then click a link on that pre-logon page, which then returns a login form page, and then fill in information in the form page and submit it.
      How can I handle that using AutoIT?
      I can get the AutoIT script to tab to the link, then send an ENTER, which then causes the FORM page to appear in IE.  However, I cannot seem to get the form object from the FORM page (_IEFormGetObjByName fails when it searches for the form).  Why is that, and how can I get the AutoIT to process the FORM page?
      Thanks,
      Jim
    • JuanFelipe
      By JuanFelipe
      Hello friends, I have a simple question, can I have a variable that is not reset, even if my program is closed?
      That is, I want to make a program that can only be opened once, have a variable $ ini = 0, when it is opened for the first and only time it becomes $ ini = 1, so that it can not use the program a second time, as if it was a test software.
      I do not want the variable to depend on a reading of an external file that is easily manipulated. Thank you.
    • nooneclose
      By nooneclose
      My program has to first search for names in Column D that do not match up with column C. I got that search to work using arrays. It was slow and I could not figure out how to delete them so I just manually put coded the names that do not belong. I found their cell location but I do not know how to store that location and delete it.
      This is what I have so far.
      Local $NameToDelete1[6]  = _Excel_RangeFind($OpenWorkbook, "Smith, Bill") _ArrayDisplay($NameToDelete1, "Excel UDF: _Excel_RangeFind Example 1", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment") _Excel_RangeDelete($OpenWorkbook.ActiveSheet, $NameToDelete1[2], $xlShiftUp)  
      Please help, I wanted to have this program done yesterday but I did not see this problem until yesterday. 
    • TrashBoat
      By TrashBoat
      So Im trying to make a simple 2d game and make some sort of collision detection so why not to make a 2 dimensional array but i have no clue how  to write it in multiple lines
      Global $map[5,5] = [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0 _ [0,0,0,0,0] something like this but it doesn't work
    • Zein
      By Zein
      #include "..\Include\Array.au3" #include "..\Include\File.au3" #include "..\Include\AutoItConstants.au3" Local $aRetArray Local $sFilePath = "n.csv" _FileReadToArray($sFilePath, $aRetArray, ",") ; _FileReadToArray($sFilePath, $aRetArray, $FRTA_COUNT, ",") _ArrayDisplay($aRetArray, "Original", Default, 8) The above code shows two versions of _FileReadToArray and both don't work as expected.
      The first one doesn't use the comma as a delimiter. (so I get a single column array)  I tried adding "Default" between $aRetArray and "," then it told me it had an incorrect number of parameters. 

      I looked again at the documentation:
       
      #include <File.au3> _FileReadToArray ( $sFilePath, ByRef $vReturn [, $iFlags = $FRTA_COUNT [, $sDelimiter = ""]] )
      And I with or without the flags params I should be getting a 2D array due to my file being a csv. 
      I then tried a regular flag, $FRTA_COUNT, and it tells me that I'm using a variable $FRTA_COUNT while it's not declared. Tried putting in 1 instead and it told me again, incorrect number of params. 

       
×