|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How do I change the radiobutton when listbox selection has changedI have 3 radio buttons for include, exclued or 'select all' from the listbox
items. If a user selects the 'Select All' button' then all items in listbox is hi-lited as selected. Now, when user selects one item out of the 'all selected' listing then there is now only one item selected. How and where can I put in some code to change the selected radio button to the 'include' since it is no longer in select all mode. Thanks, Alpha Take a look at implementing the OnSelectedIndexChanged event and that will
reveal in your code which items are selected and from there you can programmatically change the radio buttons. Here is the article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistboxclassonselectedindexchangedtopic.asp Show quoteHide quote "Alpha" <Al***@discussions.microsoft.com> wrote in message news:DAAC91A0-B8A0-4842-A406-F6A0FBC3A8EF@microsoft.com... >I have 3 radio buttons for include, exclued or 'select all' from the >listbox > items. If a user selects the 'Select All' button' then all items in > listbox > is hi-lited as selected. Now, when user selects one item out of the 'all > selected' listing then there is now only one item selected. How and where > can I put in some code to change the selected radio button to the > 'include' > since it is no longer in select all mode. > > Thanks, > Alpha Yes, I tried that alreday. It's not working properly because I also have
code for when that radio button status changed. It's interferring with the listbox selectedindeschange. It took care of de-selecting the 'Include all' radio button and select the Include all button. But the new problem with this code is now when I select the 'Select All' radio button it will flash the radio button was check in the blink of an eye and then uncheck it and check the 'Incldue' radio button even when the entire list is selected. Is there anyway around this? Thanks, Alpha if (radioAllItems.Checked == true) { // for (int x = 0; x < this.lstSelections.Items.Count; x++) // { // this.lstSelections.SetSelected(x, true); // } this.Show(); // Do focused work here. if (this.listBox1.Items.Count > 0) { this.listBox1.Focus(); this.listBox1.SetSelected(0, true); SendKeys.Send("+{END}"); } } else lstSelections.ClearSelected(); } private void lstSelections_SelectedIndexChanged(object sender, System.EventArgs e) { if (radioAllItems.Checked == true) if (this.lstSelections.SelectedItems.Count < lstSelections.Items.Count) { radioAllItems.Checked = false; radioInclude.Checked = true; } } Show quoteHide quote "Alex Passos" wrote: > Take a look at implementing the OnSelectedIndexChanged event and that will > reveal in your code which items are selected and from there you can > programmatically change the radio buttons. Here is the article: > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistboxclassonselectedindexchangedtopic.asp > > "Alpha" <Al***@discussions.microsoft.com> wrote in message > news:DAAC91A0-B8A0-4842-A406-F6A0FBC3A8EF@microsoft.com... > >I have 3 radio buttons for include, exclued or 'select all' from the > >listbox > > items. If a user selects the 'Select All' button' then all items in > > listbox > > is hi-lited as selected. Now, when user selects one item out of the 'all > > selected' listing then there is now only one item selected. How and where > > can I put in some code to change the selected radio button to the > > 'include' > > since it is no longer in select all mode. > > > > Thanks, > > Alpha > > > You could create a flag to indicate the listbox is changing and not do your
code for the radio button when it is changing. See below. bool listBoxChanging in your Select Index Change listBoxChanging = true; do your code here listBoxChanging = false; In the Radio button index change if !listBoxChanging { existing code } -- Show quoteHide quoteThanks Wayne Sepega Jacksonville, Fl "When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein "Alpha" <Al***@discussions.microsoft.com> wrote in message http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistboxclassonselectedindexchangedtopic.aspnews:218A41BF-C815-4F92-A872-550587A78554@microsoft.com... > Yes, I tried that alreday. It's not working properly because I also have > code for when that radio button status changed. It's interferring with the > listbox selectedindeschange. It took care of de-selecting the 'Include all' > radio button and select the Include all button. But the new problem with > this code is now when I select the 'Select All' radio button it will flash > the radio button was check in the blink of an eye and then uncheck it and > check the 'Incldue' radio button even when the entire list is selected. Is > there anyway around this? > > Thanks, > Alpha > > if (radioAllItems.Checked == true) > { > // for (int x = 0; x < this.lstSelections.Items.Count; x++) > // { > // this.lstSelections.SetSelected(x, true); > // } > > this.Show(); > > // Do focused work here. > > if (this.listBox1.Items.Count > 0) > { > this.listBox1.Focus(); > this.listBox1.SetSelected(0, true); > SendKeys.Send("+{END}"); > } > > } > else > lstSelections.ClearSelected(); > } > > private void lstSelections_SelectedIndexChanged(object sender, > System.EventArgs e) > { > if (radioAllItems.Checked == true) > if (this.lstSelections.SelectedItems.Count < lstSelections.Items.Count) > { > radioAllItems.Checked = false; > radioInclude.Checked = true; > } > > } > > > "Alex Passos" wrote: > > > Take a look at implementing the OnSelectedIndexChanged event and that will > > reveal in your code which items are selected and from there you can > > programmatically change the radio buttons. Here is the article: > > > > Show quoteHide quote > > > > "Alpha" <Al***@discussions.microsoft.com> wrote in message > > news:DAAC91A0-B8A0-4842-A406-F6A0FBC3A8EF@microsoft.com... > > >I have 3 radio buttons for include, exclued or 'select all' from the > > >listbox > > > items. If a user selects the 'Select All' button' then all items in > > > listbox > > > is hi-lited as selected. Now, when user selects one item out of the 'all > > > selected' listing then there is now only one item selected. How and where > > > can I put in some code to change the selected radio button to the > > > 'include' > > > since it is no longer in select all mode. > > > > > > Thanks, > > > Alpha > > > > > > Nop, it's not working. I'm setting the same button in both event and it's
conflicting with each other. You'll see that if you look at my code posted previously. I tried setting flags in both events (codes below) and it still doesn't work right. I wonder how does people handel issue like this. Well, I give up. I'm going to remove the 'select all' button option. Thank you for your help anyway. Alpha Show quoteHide quote "Wayne" wrote: > You could create a flag to indicate the listbox is changing and not do your > code for the radio button when it is changing. See below. > > bool listBoxChanging > > in your Select Index Change > listBoxChanging = true; > do your code here > listBoxChanging = false; > > In the Radio button index change > if !listBoxChanging > { > existing code > } > > -- > Thanks > Wayne Sepega > Jacksonville, Fl > > > "When a man sits with a pretty girl for an hour, it seems like a minute. But > let him sit on a hot stove for a minute and it's longer than any hour. > That's relativity." - Albert Einstein > > "Alpha" <Al***@discussions.microsoft.com> wrote in message > news:218A41BF-C815-4F92-A872-550587A78554@microsoft.com... > > Yes, I tried that alreday. It's not working properly because I also have > > code for when that radio button status changed. It's interferring with > the > > listbox selectedindeschange. It took care of de-selecting the 'Include > all' > > radio button and select the Include all button. But the new problem with > > this code is now when I select the 'Select All' radio button it will flash > > the radio button was check in the blink of an eye and then uncheck it and > > check the 'Incldue' radio button even when the entire list is selected. > Is > > there anyway around this? > > > > Thanks, > > Alpha > > > > if (radioAllItems.Checked == true) > > { > > // for (int x = 0; x < this.lstSelections.Items.Count; x++) > > // { > > // this.lstSelections.SetSelected(x, true); > > // } > > > > this.Show(); > > > > // Do focused work here. > > > > if (this.listBox1.Items.Count > 0) > > { > > this.listBox1.Focus(); > > this.listBox1.SetSelected(0, true); > > SendKeys.Send("+{END}"); > > } > > > > } > > else > > lstSelections.ClearSelected(); > > } > > > > private void lstSelections_SelectedIndexChanged(object sender, > > System.EventArgs e) > > { > > if (radioAllItems.Checked == true) > > if (this.lstSelections.SelectedItems.Count < lstSelections.Items.Count) > > { > > radioAllItems.Checked = false; > > radioInclude.Checked = true; > > } > > > > } > > > > > > "Alex Passos" wrote: > > > > > Take a look at implementing the OnSelectedIndexChanged event and that > will > > > reveal in your code which items are selected and from there you can > > > programmatically change the radio buttons. Here is the article: > > > > > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistboxclassonselectedindexchangedtopic.asp > > > > > > "Alpha" <Al***@discussions.microsoft.com> wrote in message > > > news:DAAC91A0-B8A0-4842-A406-F6A0FBC3A8EF@microsoft.com... > > > >I have 3 radio buttons for include, exclued or 'select all' from the > > > >listbox > > > > items. If a user selects the 'Select All' button' then all items in > > > > listbox > > > > is hi-lited as selected. Now, when user selects one item out of the > 'all > > > > selected' listing then there is now only one item selected. How and > where > > > > can I put in some code to change the selected radio button to the > > > > 'include' > > > > since it is no longer in select all mode. > > > > > > > > Thanks, > > > > Alpha > > > > > > > > > > > >
Other interesting topics
Break out of Try
include build time in exe file C# Reflection - Nasty bug?? xpath in c# If statement with multiple condition Control-click Start and exit applcation(s) using Windows Services deployment of dot net desktop project with crystal reports HELP Problem serializing a structure Splitting a string array to seperate variables |
|||||||||||||||||||||||