Sign in to follow this  
Followers 0
randallc

GUICtrlListView

5 posts in this topic

Hi,

I am not too good on GUI.

Can someone please help?

1. _GUICtrlListView; can I change a header name?

2. _GUICtrlListViewMoveColumn - is this possible (ie I don't just want to change column order, I want to change the index numbers?)

Thanks, Randall

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

I am not too good on GUI.

Can someone please help?

1. _GUICtrlListView; can I change a header name?

2. _GUICtrlListViewMoveColumn - is this possible (ie I don't just want to change column order, I want to change the index numbers?)

Thanks, Randall

1:

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status
GUICreate("ListView Set Column Header Text", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, -1, BitOR($LVS_EX_REGIONAL, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
$Status = GUICtrlCreateLabel("Remember columns are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
If (_GUICtrlListViewJustifyColumn ($listview, 1, 2)) Then
   GUICtrlSetData($Status, 'Justify column: 2 Successful')
Else
   GUICtrlSetData($Status, 'Failed to Justify column: 2')
EndIf
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
_GUICtrlListViewSetColumnWidth ($listview, 0, 75)
_GUICtrlListViewSetColumnWidth ($listview, 1, 75)
_GUICtrlListViewSetColumnWidth ($listview, 2, 75)
_GUICtrlListViewSetColumnHeaderText($listview, 1, "new text")
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)

GUISetState()
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
         ExitLoop
   EndSelect
WEnd
Exit

;===============================================================================
;
; Description:              _GUICtrlListViewSetColumnHeaderText
; Parameter(s):         $h_listview - controlID
;                               $i_col - Zero based index of column Justify
;                               $s_text - New text for column header
; Requirement:              None
; Return Value(s):      Returns TRUE if successful, or FALSE otherwise
;                               if error then $LV_ERR is returned
; User CallTip:         _GUICtrlListViewSetColumnHeaderText($h_listview, $i_col, $s_text) Change the text of a column header for a list-view control (required: <GuiListView.au3>)
; Author(s):                Gary Frost (custompcs@charter.net)
; Note(s):
;
;===============================================================================
Func _GUICtrlListViewSetColumnHeaderText($h_listview, $i_col, $s_text)
   Local $struct = "uint;int;int;ptr;int;int;int;int", $p, $ret, $sp
   $sp = DllStructCreate("char[" & StringLen($s_text) + 1 & "]")
   If @error Then
      Return $LV_ERR
   EndIf
   DllStructSetData($sp, 1, $s_text)
   $p = DllStructCreate($struct)
   If @error Then
      $sp = 0
      Return $LV_ERR
   EndIf
   DllStructSetData($p, 1, $LVCF_TEXT)
   DllStructSetData($p, 4, DllStructGetPtr($sp))
   If IsHWnd($h_listview) Then
      Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_listview, "int", $LVM_SETCOLUMNA, "int", $i_col, "ptr", DllStructGetPtr($p))
      $ret = $a_ret[0]
   Else
      $ret = GUICtrlSendMsg($h_listview, $LVM_SETCOLUMNA, $i_col, DllStructGetPtr($p))
   EndIf
  ;   DllStructDelete($p)
   Return $ret
EndFunc  ;==>_GUICtrlListViewSetColumnHeaderText

2: not that I can see

Gary

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Hey, Magic,

Thanks so much!

1. _GUICtrlListViewSetColumnHeaderText

Did you just do that, or had you already done it!?

I'll try it; It should save me deleting, then re-creating a list view every time I change the required columns...?

[** or am i missing something; is there another way to do that?]

2. _GUICtrlListViewMoveColumn

I guess I just do a UDF;

copy items to the column i want in a loop, then delete the orig column?

[** I presume I have to re-create each line to include the data of the extra column?; no "_GUICtrlListViewReplaceColumnItem " at a certain row?]

Have you done that too?/..

best, Randall

Share this post


Link to post
Share on other sites

1. _GUICtrlListViewSetColumnHeaderText

Did you just do that, or had you already done it!?

I'll try it; It should save me deleting, then re-creating a list view every time I change the required columns...?

[** or am i missing something; is there another way to do that?]

Just wrote that one up real quick

2. _GUICtrlListViewMoveColumn

I guess I just do a UDF;

copy items to the column i want in a loop, then delete the orig column?

[** I presume I have to re-create each line to include the data of the extra column?; no "_GUICtrlListViewReplaceColumnItem " at a certain row?]Have you done that too?/..

Take a look at _GUICtrlListViewSetItemText($h_listview, $i_index, $i_subitem, $s_text)

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hey, Magic,

Thanks so much!

1. _GUICtrlListViewSetColumnHeaderText

Did you just do that, or had you already done it!?

I'll try it; It should save me deleting, then re-creating a list view every time I change the required columns...?

[** or am i missing something; is there another way to do that?]

2. _GUICtrlListViewMoveColumn

I guess I just do a UDF;

copy items to the column i want in a loop, then delete the orig column?

[** I presume I have to re-create each line to include the data of the extra column?; no "_GUICtrlListViewReplaceColumnItem " at a certain row?]

Have you done that too?/..

best, Randall

Wow, old thread but I'd like to know if you could develop point number 2 ?

How did you proceed, any fast solution as I could use these within a very large listview ..

Well thank you in advance for any information given. !! ;)

Thank you Gary for _GUICtrlListViewSetColumnHeaderText, didn't try yet but it will prove very useful. :)

hench

Edited by hench

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