Champak Posted March 3, 2014 Posted March 3, 2014 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.
FireFox Posted March 3, 2014 Posted March 3, 2014 (edited) _GUICtrlListView_GetItemCount ? Edited March 3, 2014 by FireFox
Champak Posted March 3, 2014 Author Posted March 3, 2014 (edited) 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 March 3, 2014 by Champak
jdelaney Posted March 3, 2014 Posted March 3, 2014 (edited) Grab current selected row, append it's row number to the title (header) via: _GUICtrlListView_SetColumn Edited March 3, 2014 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.
Champak Posted March 3, 2014 Author Posted March 3, 2014 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.
jdelaney Posted March 3, 2014 Posted March 3, 2014 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.
FireFox Posted March 3, 2014 Posted March 3, 2014 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 : expandcollapse popup#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
jdelaney Posted March 3, 2014 Posted March 3, 2014 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.
Champak Posted March 3, 2014 Author Posted March 3, 2014 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.
Moderators Melba23 Posted March 3, 2014 Moderators Posted March 3, 2014 Champak,You have UEZ to thank for this:expandcollapse popup#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_NotifyYou 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
DW1 Posted March 3, 2014 Posted March 3, 2014 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. AutoIt3 Online Help
jdelaney Posted March 3, 2014 Posted March 3, 2014 Ha, we were way off. 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.
Champak Posted March 3, 2014 Author Posted March 3, 2014 (edited) 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 March 3, 2014 by Champak
FireFox Posted March 3, 2014 Posted March 3, 2014 (edited) The only reason I see is to hide the scrollbar of the index listview. Edited March 3, 2014 by FireFox
Moderators Melba23 Posted March 3, 2014 Moderators Posted March 3, 2014 (edited) Champak, Is there a reason a child GUI was used that I'm not seeingIt prevents the scrollbar displaying in the "Index" ListView when it appears- that bit was my contribution to the script. M23Edit:FireFox, Edited March 3, 2014 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Champak Posted March 3, 2014 Author Posted March 3, 2014 (edited) 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 March 3, 2014 by Champak
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