Sign in to follow this  
Followers 0
Vier

Problem with ListView

11 posts in this topic

Hello,

I create a listview, and I would like suppress a selected item with a button, and all item with another button :

Case $msg[0] = $arrayuser[6]

_GUICtrlListViewDeleteItemsSelected($listuser)

Case $msg[0] = $arrayuser[7]

_GUICtrlListViewDeleteAllItems($listuser)

In the second case All item suppress, but in first case the item selected not suppress ?

Share this post


Link to post
Share on other sites



Hello,

I create a listview, and I would like suppress a selected item with a button, and all item with another button :

Case $msg[0] = $arrayuser[6]

_GUICtrlListViewDeleteItemsSelected($listuser)

Case $msg[0] = $arrayuser[7]

_GUICtrlListViewDeleteAllItems($listuser)

In the second case All item suppress, but in first case the item selected not suppress ?

Think you'll need to supply a little more info, and maybe some more script.

What is $arrayuser? is it an array of buttons? or is it just an array of info?


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

$arrayuser is an array of buttons :

$arrayuser[6]=GUICtrlCreateButton(IniRead($vxp_lang_f,"MUser",9,""),10,300,230,30)

$arrayuser[7]=GUICtrlCreateButton(IniRead($vxp_lang_f,"MUser",10,""),10,340,230,30)

The buttons and ListView are in a child window. I suppose that the the problem is arrayuser[6] and test with a simply $arrayuser2 (not array) and the same propblem appear

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I've had problems deleting items with _GuiCtrlListViewDeleteItemsSelected() before.

I've found sending the $LVM_DELETEITEM message works every time.

Try this code to delete (suppress?) a selected ListView item:

Dim $iSelectedIndex
Dim $MSG_DELETEITEM = 0x1008

$iSelectedIndex = _GUICtrlListViewGetCurSel($listuser)
GUICtrlSendMsg($listuser, $MSG_DELETEITEM, $iSelectedIndex, 0)

EDIT: Renamed the $LVM_DELETEITEM variable to $MSG_DELETEITEM. $LVM_DELETEITEM can conflict if you've included GuiListView.au3 to your script.

Edited by tonedeaf

Share this post


Link to post
Share on other sites

Thanks Tonedeaf : the code is good !

I have another problem I would like take all item from listview to an inifile my code :

$nuser = _GUICtrlListViewGetItemCount ($listuser)

IniWrite($projetini,"WINNT","adduser",$nuser)

If $nuser > 0 Then

IniDelete($Projetini,"Users")

For $i = 0 to $nuser - 1

$a_item = _GUICtrlListViewGetItemText($listuser,$i)

MsgBox(0, "Selected Item, SubItem 0", $a_item)

IniWrite($projetini,"Users",$i+1,$a_item)

Next

EndIf

_GUICtrlListViewGetItemCount ($listuser) return number of index. But _GUICtrlListViewGetItemText($listuser,$i) not retrieve information ?

Share this post


Link to post
Share on other sites

Hello,

I create a listview, and I would like suppress a selected item with a button, and all item with another button :

Case $msg[0] = $arrayuser[6]

_GUICtrlListViewDeleteItemsSelected($listuser)

Case $msg[0] = $arrayuser[7]

_GUICtrlListViewDeleteAllItems($listuser)

In the second case All item suppress, but in first case the item selected not suppress ?

being these are in a child window you are better off using the optional window title parameter

Case $msg[0] = $arrayuser[6]
_GUICtrlListViewDeleteItemsSelected($listuser, "Title of Child Window")

Case $msg[0] = $arrayuser[7]
_GUICtrlListViewDeleteAllItems($listuser)

$nuser = _GUICtrlListViewGetItemCount ($listuser)
IniWrite($projetini, "WINNT", "adduser", $nuser)
If $nuser > 0 Then
 IniDelete($projetini, "Users")
 For $i = 0 To $nuser - 1
  $a_item = _GUICtrlListViewGetItemText ($listuser, $i, -1, "Title of Child Window")
  MsgBox(0, "Selected Item, SubItem 0", $a_item)
  IniWrite($projetini, "Users", $i + 1, $a_item)
 Next
EndIf

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

Or use ControlListView() function to retrieve information for the selected item.

Replace $gui with your window handle which is returned by GuiCreate()

$a_Item = ControlListView($gui, "", $listuser, "GetText", $i)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Or use ControlListView() function to retrieve information for the selected item.

Replace $gui with your window handle which is returned by GuiCreate()

$a_Item = ControlListView($gui, "", $listuser, "GetText", $i)

Same can be done with my example in previous post, you can replace the "Title of Child Window" with the window handle created by the GuiCreate()

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

@gafrost

Yes that's correct.

BTW - I also wanted to know if the UDF you created for managing any control (both internal and external to AutoIt) has been included in the Beta version?

Share this post


Link to post
Share on other sites

@gafrost

Yes that's correct.

BTW - I also wanted to know if the UDF you created for managing any control (both internal and external to AutoIt) has been included in the Beta version?

Yes for GuiCombo, GuiEdit, GuiList, GuiListView, GuiMonthCal, GuiTab


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

With title window parameter : no problem for retrieve information !

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