Jump to content

Problem with ListView


Vier
 Share

Recommended Posts

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 ?

Link to comment
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.

 

Link to comment
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

Link to comment
Share on other sites

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
Link to comment
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 ?

Link to comment
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.

 

Link to comment
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)

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.

 

Link to comment
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.

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...