incepator

_GUICtrlListView_InsertGroup

10 posts in this topic

Hello friends,
I need a little help to finish this code.
Although it seems simple, I messed up.
I just want to add when I want, groups and items using two separate buttons.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
$z2 = 0
$act_group = 0
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 263, 173, 384, 268)
$Button1 = GUICtrlCreateButton("Add Group", 8, 8, 75, 25)
$Button2 = GUICtrlCreateButton("Add item", 88, 8, 75, 25)
$ListView1 = GUICtrlCreateListView("data", 8, 40, 250, 126)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_GUICtrlListView_EnableGroupView($ListView1)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $act_group = $act_group +1
            GUICtrlCreateListViewItem("Wait for new item...", $ListView1)
            GUICtrlSetState($Button1, $GUI_DISABLE)
            _GUICtrlListView_InsertGroup($ListView1, -1, $act_group, "Group "&$act_group)
            _GUICtrlListView_SetItemGroupID($ListView1, 0, $act_group)
        Case $Button2
            If _GUICtrlListView_GetItemCount($ListView1) = 0 Then
                GUICtrlCreateListViewItem(_GUICtrlListView_GetItemCount($ListView1) + 1, $ListView1)
                _GUICtrlListView_InsertGroup($ListView1, -1, 1, "Group 1")
                _GUICtrlListView_SetItemGroupID($ListView1, 0, 1)
            ElseIf _GUICtrlListView_GetItemText($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1) = "Wait for new item..." Then
                _GUICtrlListView_SetItem($ListView1, "1", _GUICtrlListView_GetItemCount($ListView1) - 1)
            Else
                $z2 = $z2 + 1
                GUICtrlCreateListViewItem(_GUICtrlListView_GetItemCount($ListView1) + 1, $ListView1)
                For $z = 1 To _GUICtrlListView_GetItemCount($ListView1) + 1
                    _GUICtrlListView_SetItemGroupID($ListView1, $z2, 1)
                Next
            EndIf
            GUICtrlSetState($Button1, $GUI_ENABLE)
    EndSwitch
WEnd

;_GUICtrlListView_SetGroupInfo($ListView1, 1, "New Group 1", 1, $LVGS_COLLAPSIBLE)
;_GUICtrlListView_SetGroupInfo($ListView1, 2, "New Group 2", 1, $LVGS_COLLAPSIBLE); <--- Not applied

Thank you.

Share this post


Link to post
Share on other sites



Please help me...i need for this example.

Share this post


Link to post
Share on other sites

@incepator,

Please do not bump your own threads within 24 hours.
Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare.  You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@Jos May the force be with me.
I have tried in many ways, but I get lost in that equation.

Thanks for the reply, I'll be waiting...

Share this post


Link to post
Share on other sites

I was about to helping you. Bu I really don't got what you want to do :S

 

Saludos

Share this post


Link to post
Share on other sites

Ok @Danyfirex thank you.

Forget the example above, I've attached a sample example at the bottom.

When press the button "Add Group" I want to add a new group ( _GUICtrlListView_InsertGroup), not a list view ( GUICtrlCreateListViewItem).

 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
$act_group = 0
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 263, 173, 384, 268)
$Button1 = GUICtrlCreateButton("Add Group", 8, 8, 75, 25)
$Button2 = GUICtrlCreateButton("Add item", 88, 8, 75, 25)
$ListView1 = GUICtrlCreateListView("Data", 8, 40, 250, 126)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $act_group = $act_group + 1
            GUICtrlCreateListViewItem("Group " & $act_group, $ListView1)
        Case $Button2
            GUICtrlCreateListViewItem("Item", $ListView1)
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites

Maybe this.

 

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

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Enable Group View", 400, 330)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    $ibtnAdd = GUICtrlCreateButton("Add Group", 170, 290, 80, 30)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)


    ; Add columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)


    Local $iIndex = 0
    Local $idMsg = 0
    While 1
        $idMsg = GUIGetMsg()
        Select
            Case $idMsg = $GUI_EVENT_CLOSE
                Exit
            Case $idMsg = $ibtnAdd
                $iIndex = _GUICtrlListView_GetItemCount($idListview)
                _GUICtrlListView_AddItem($idListview, "Item " & $iIndex + 1)
                _GUICtrlListView_InsertGroup($idListview, -1, $iIndex + 1, "Group " & $iIndex + 1)
                _GUICtrlListView_SetItemGroupID($idListview, $iIndex, $iIndex + 1)
        EndSelect
    WEnd

    GUIDelete()
EndFunc   ;==>Example

Saludos

Share this post


Link to post
Share on other sites

Yes, i know that , but i need another one button "Add Item", when i want to add a new item...
Probably, when I press this button, need to be calculated actual position of table and using again the function _GUICtrlListView_SetItemGroupID

Share this post


Link to post
Share on other sites

Lol Sorry I forgot to press submit button lol

 

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

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Enable Group View", 400, 330)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    $ibtnAdd = GUICtrlCreateButton("Add Group", 100, 290, 80, 30)
    $ibtnAdditem = GUICtrlCreateButton("Add Item", 200, 290, 80, 30)
    GUISetState(@SW_SHOW)


    ; Add columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)


    Local $iIndex = 0
    Local $idMsg = 0
    Local $iIndexGroup = 1
    Local $iCount = 0
    Local $iTempGroup = 0
    While 1
        $idMsg = GUIGetMsg()
        Select
            Case $idMsg = $GUI_EVENT_CLOSE
                Exit
            Case $idMsg = $ibtnAdd
                $iIndex = _GUICtrlListView_GetItemCount($idListview)
                _GUICtrlListView_AddItem($idListview, "Waiting for Item")
                _GUICtrlListView_InsertGroup($idListview, $iIndex, $iIndexGroup, "Group " & $iIndexGroup)
                _GUICtrlListView_SetItemGroupID($idListview, $iIndex, $iIndexGroup)
                $iTempGroup = $iIndexGroup
                $iIndexGroup += 1
                $iCount = 1
            Case $idMsg = $ibtnAdditem
                $iIndex = _GUICtrlListView_GetItemCount($idListview)
                If $iCount = 1 Then _GUICtrlListView_SetItemText($idListview, $iIndex - 1, "Item " & $iCount)

                If $iCount > 1 Then
                    _GUICtrlListView_AddItem($idListview, "Item " & $iCount)
                    _GUICtrlListView_SetItemGroupID($idListview, $iIndex, $iTempGroup)
                EndIf
                $iCount += 1
        EndSelect
    WEnd

    GUIDelete()
EndFunc   ;==>Example

 

It is not the most elegant way. but I think it does what you want.

Saludos

1 person likes this

Share this post


Link to post
Share on other sites

Yes, this is very good for me.
 Thank you very much,

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