469,903 Members | 2,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

How do I change the radiobutton when listbox selection has changed

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
Nov 17 '05 #1
3 3314
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/de...angedtopic.asp

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.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

Nov 17 '05 #2
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/de...angedtopic.asp

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.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


Nov 17 '05 #3
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:21**********************************@microsof t.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/de...angedtopic.asp
"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.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


Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by William Gill | last post: by
3 posts views Thread by dave | last post: by
6 posts views Thread by Chris Leuty | last post: by
reply views Thread by member | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.