Jump to content

Radio Buttons in Listview?


Recommended Posts

I want a listview with radio buttons. But I can't figure it out. Here's what I ahve, but multiple boxes are selectable.

$every = GUICtrlCreateListView("radio", 200, 160, 180, 40, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($every, 0, 175)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_SINGLESEL, $LVS_SINGLESEL)
GUICtrlCreateListViewItem("Weekly", $every)
GUICtrlCreateListViewItem("Only For the Next Week", $every)
GUISetState()

Coming soon....

Link to comment
Share on other sites

I want a listview with radio buttons. But I can't figure it out. Here's what I ahve, but multiple boxes are selectable.

$every = GUICtrlCreateListView("radio", 200, 160, 180, 40, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($every, 0, 175)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_SINGLESEL, $LVS_SINGLESEL)
GUICtrlCreateListViewItem("Weekly", $every)
GUICtrlCreateListViewItem("Only For the Next Week", $every)
GUISetState()

Radio? no, CheckBoxes, yes

GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
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

Can you help with that,everything I've tried doesn't seeem to work.

I'm not sure how to make this function:

Func _weekly()
    $every2 = GUIctrlread(GUIctrlread($every))
Select
Case StringInStr($every2, "Weekly")
    I don't know what to put here
Case StringInStr($every2, "Only")
    I don't know what to put here
EndSelect
GUISetState()
EndFunc

Coming soon....

Link to comment
Share on other sites

I knew I could figure this out eventually... it was more complicated than I thought, because I didn't realize ListViews were so... different. Anyway, here's a result.

GUICreate ("")
$every = GUICtrlCreateListView("radio", 200, 160, 180, 40, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($every, 0, 175)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_SINGLESEL, $LVS_SINGLESEL)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
$ListViewItemWeekly = GUICtrlCreateListViewItem("Weekly", $every)
$ListViewItemNextWeek = GUICtrlCreateListViewItem("Only For the Next Week", $every)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $ListViewItemWeekly Then
        _GUICtrlListViewSetCheckState ($every, 1, 0)
    ElseIf $msg = $ListViewItemNextWeek Then
        _GUICtrlListViewSetCheckState ($every, 0, 0)
    ElseIf $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    Sleep (1)
WEnd
Link to comment
Share on other sites

I needed to modify the code slightly to

Select
Case  _GUICtrlListViewGetCheckedState($every, 0) = 1
    _GUICtrlListViewSetCheckState ($every, 1, 0)
    $every2 = "Only For the Next Week"
Case _GUICtrlListViewGetCheckedState($every, 1) = 1 
    _GUICtrlListViewSetCheckState ($every, 0, 0)
    $every2 = "Weekly"
EndSelect

And now, one I select Weekly, I cannot change my selection. Is there any way around this?

Coming soon....

Link to comment
Share on other sites

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

GUICreate ("")
$every = GUICtrlCreateListView("radio", 200, 160, 180, 40, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($every, 0, 175)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_SINGLESEL, $LVS_SINGLESEL)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
$ListViewItemWeekly = GUICtrlCreateListViewItem("Weekly", $every)
$ListViewItemNextWeek = GUICtrlCreateListViewItem("Only For the Next Week", $every)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $ListViewItemWeekly Then
        _GUICtrlListViewSetCheckState ($every, 0, 1)
        _GUICtrlListViewSetCheckState ($every, 1, 0)
    ElseIf $msg = $ListViewItemNextWeek Then
        _GUICtrlListViewSetCheckState ($every, 0, 0)
        _GUICtrlListViewSetCheckState ($every, 1, 1)
    ElseIf $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    Sleep (1)
WEnd

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

$file = FileOpen("blankfile.txt", 1)

; Check if file opened for writing OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileClose($file)

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

  • 1 year later...

I know, this is an old thread, but i am working on this issue and maybe someone looking for a way to seperate checkbox and itemstates completely (checkbox only checked when clicked, but not on item selected) might find this slight variant useful:

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

GUICreate ("")
$every = GUICtrlCreateListView("radio", 200, 160, 180, 40, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($every, 0, 175)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_BORDERSELECT, $LVS_EX_BORDERSELECT)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_SINGLESEL, $LVS_SINGLESEL)
GUICtrlSendMsg($every, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
$ListViewItemWeekly = GUICtrlCreateListViewItem("Weekly", $every)
$ListViewItemNextWeek = GUICtrlCreateListViewItem("Only For the Next Week", $every)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $ListViewItemWeekly Then
        If _GUICtrlListViewGetCheckedState($every,0) Then _GUICtrlListViewSetCheckState ($every, 1, 0)
    ElseIf $msg = $ListViewItemNextWeek Then
        If _GUICtrlListViewGetCheckedState($every,1) Then _GUICtrlListViewSetCheckState ($every, 0, 0)
    ElseIf $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
    Sleep (1)
WEnd

good night

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

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...