MikelSevrel Posted February 25, 2006 Share Posted February 25, 2006 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 More sharing options...
GaryFrost Posted February 25, 2006 Share Posted February 25, 2006 (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 February 25, 2006 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 More sharing options...
MikelSevrel Posted February 25, 2006 Author Share Posted February 25, 2006 Yeah, I can do that, ut I need only one to be selectable at a time. Coming soon.... Link to comment Share on other sites More sharing options...
greenmachine Posted February 25, 2006 Share Posted February 25, 2006 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. Link to comment Share on other sites More sharing options...
MikelSevrel Posted February 25, 2006 Author Share Posted February 25, 2006 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 More sharing options...
greenmachine Posted February 25, 2006 Share Posted February 25, 2006 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 More sharing options...
MikelSevrel Posted February 25, 2006 Author Share Posted February 25, 2006 THanks, that finished it up perfectly! Coming soon.... Link to comment Share on other sites More sharing options...
MikelSevrel Posted February 26, 2006 Author Share Posted February 26, 2006 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 More sharing options...
GaryFrost Posted February 26, 2006 Share Posted February 26, 2006 #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 More sharing options...
MikelSevrel Posted February 26, 2006 Author Share Posted February 26, 2006 (edited) Thanks. Edited February 26, 2006 by MikelSevrel Coming soon.... Link to comment Share on other sites More sharing options...
GaryFrost Posted February 26, 2006 Share Posted February 26, 2006 $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 More sharing options...
jennico Posted January 13, 2008 Share Posted January 13, 2008 (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 January 13, 2008 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now