Jump to content
Sign in to follow this  
Champak

Listview row count

Recommended Posts

Champak

Is there a quick style, attribute, function I can use to add the row count on a listview?

I could have sworn I saw this before and I just can't find it. I don't want to have to add another column and inject the row numbers which will force me to change around some code that looks for the column. Something like the header, but row count instead.

Share this post


Link to post
Share on other sites
FireFox

_GUICtrlListView_GetItemCount ?

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Champak

No, that gets the total count. I want to pretty much insert a third column...rather a first column...that shows the row number without actually changing the column count. Like a vertical header of sorts, like how you have the header/title, but it doesn't actually count as a row.

Edited by Champak

Share this post


Link to post
Share on other sites
jdelaney

Grab current selected row, append it's row number to the title (header) via:

_GUICtrlListView_SetColumn

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Champak

But that would be changing the column count won't it? (I'm not at home to test it out) which I wouldn't want to do because I would have to go and change around a bunch of other code.

Just to clarify once again...only because I just thought of this and it made more sense to me...I want my first column to be just like excel. The row count is there, but it doesn't count as an actual column.

But it's looking like it isn't possible.

Share this post


Link to post
Share on other sites
jdelaney

By appending the data to the first column header, you neither create a new row, or a new column.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
FireFox

I want my first column to be just like excel. The row count is there, but it doesn't count as an actual column.

I don't have this in my excel...

Try this :

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

Local $hGUI = GUICreate("MyGUI")

Global $_iLw1 = GUICtrlCreateListView("Col1", 10, 10, 200, 200)

_GUICtrlListView_SetColumnWidth(GUICtrlGetHandle($_iLw1), 0, 80)

Local $iBtnAdd = GUICtrlCreateButton("Add", 10, 220, 80, 22)

Local $iBtnDel = GUICtrlCreateButton("Delete", 100, 220, 80, 22)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

For $i = 1 To 10
    _LwAddItem()
Next

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $iBtnAdd
            _LwAddItem()
        Case $iBtnDel
            _LwDelItem()
    EndSwitch
WEnd

GUIDelete()

Func _LwAddItem()
    GUICtrlCreateListViewItem(Chr(Random(65, 90, 1)), $_iLw1)
EndFunc

Func _LwDelItem()
    _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($_iLw1))
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)

    Local $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    Local $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $iIDFrom
        Case $_iLw1
            Switch $iCode
                Case $LVN_INSERTITEM
                    _GUICtrlListView_SetColumn($hWndFrom, 0, "Col1 (" & _GUICtrlListView_GetItemCount($hWndFrom) & ")")
                Case $LVN_DELETEITEM
                    _GUICtrlListView_SetColumn($hWndFrom, 0, "Col1 (" & (_GUICtrlListView_GetItemCount($hWndFrom) -1) & ")")
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
jdelaney

There is a setting in excel, where the first row become the 'header' data for the columns.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Champak

OK, i see what both of you are trying to do now. Thats not what im trying to do. I need to see each row count/indices, like this excel pic. But I didnt want to add a column. I thought I saw it before without having to actually create a column and cycle through the list and input the number...like it was automatic.

post-12133-0-19953600-1393872585_thumb.p

Share this post


Link to post
Share on other sites
FireFox

AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH OK.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Melba23

Champak,

You have UEZ to thank for this:

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

Global Const $iMax = 40

Global $iPos_1 = 0, $iPos_2 = 0

$hGUI = GUICreate("Synchro Pair", 195, 240, -1, -1)
$cLV_2 = GUICtrlCreateListView("Items", 60, 5, 85, 220)
$hLV_2 = GUICtrlGetHandle($cLV_2)
GUISetState(@SW_SHOW)

$hGUI_Child = GUICreate("", 50, 220, 10, 5, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
$cLV_1 = GUICtrlCreateListView("Index", 0, 0, 85, 220)
$hLV_1 = GUICtrlGetHandle($cLV_1)
GUISetState()

For $i = 1 To $iMax
    GUICtrlCreateListViewItem($i, $cLV_1)
    GUICtrlCreateListViewItem("Item " & $i, $cLV_2)
Next

Global $aRect = _GUICtrlListView_GetItemRect($hLV_2, 0)
Global Const $iDeltaY = $aRect[3] - $aRect[1]
GUIRegisterMsg($WM_NOTIFY, "_WM_Notify")

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

Func _WM_Notify($hWnd, $Msg, $wParam, $lParam)
    Local Const $iLines = _SendMessage($hLV_2, $LVM_GETTOPINDEX) - _SendMessage($hLV_1, $LVM_GETTOPINDEX)
    _SendMessage($hLV_1, $LVM_SCROLL, 0, $iLines * $iDeltaY)
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>_WM_Notify
You should be able to integrate that into your code - let me know if you need a hand. :)

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
DW1

Why not use the listviewitem?  I understand that you do not want to do it this way, but why do you not want to do it this way?

I don't know if the listview control allows for what you are asking or not.

Share this post


Link to post
Share on other sites
Champak

Thanks. That's an interesting way to do it. I'm unable to try it now, but by looking at it, instead of creating a child GUI, why wouldn't someone just make two listview controls and then use the message notify to highlight or duplicate the actions of the "partner" listview on the same indices of the other "partner" listview? Is there a reason a child GUI was used that I'm not seeing.

Dw1, I just never used that before.

Edited by Champak

Share this post


Link to post
Share on other sites
FireFox

The only reason I see is to hide the scrollbar of the index listview.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Melba23

Champak,

 

Is there a reason a child GUI was used that I'm not seeing

It prevents the scrollbar displaying in the "Index" ListView when it appears- that bit was my contribution to the script. ;)

M23

Edit:

FireFox,

:thumbsup:

Edited by Melba23

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
Champak

Cool thanks, I definitely wouldn't want to see the scroll bars. ill try it out when I get a chance. I'm actually going to integrate it into this when I get a chance. ?do=embed' frameborder='0' data-embedContent>

Edited by Champak

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  

×