Sign in to follow this  
Followers 0
MikelSevrel

Radio Buttons in Listview?

12 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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.

 

Share this post


Link to post
Share on other sites

Yeah, I can do that, ut I need only one to be selectable at a time.


Coming soon....

Share this post


Link to post
Share on other sites

Well, if radios aren't available, couldn't you just use some commands to make the checkbox act like a radio? Like, if ___ is checked, uncheck all these others.

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

THanks, that finished it up perfectly!


Coming soon....

Share this post


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

Share this post


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

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thanks.

Edited by MikelSevrel

Coming soon....

Share this post


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

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

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

 

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