473,406 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 3519
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: William Gill | last post by:
I am placing radiobuttons in a 4 X 4 matrix (using loops) and keep references to them in a 2 dimensional list ( rBtns ). It works fine, and I can even make it so only one button per column can be...
2
by: Danny | last post by:
Hello I am trying to create a separate listbox and fill it with items based on what is in another field in a database. This field is bound to a field in the underlying database. But the data...
5
by: RBohannon | last post by:
I have a multi-selectable listbox named lstTitles. In the OnClick event I had the following: If Not IsNull(Me.lstTitles) Then ' do something with list selection Else ' do something else End...
4
by: KK | last post by:
Hi All... For my purpose, I need to handle listbox selection changed event.I must be notified before changing occurs and after.After I can handle using SelectedIndexChanged event.Is there anyway...
2
by: Alpha | last post by:
How do I change the selected item in a listbox according to a Combox's selected item on the same form? The Combox is from a different table in the same dataset as the Listbox uses. Combox's...
3
by: dave | last post by:
I have half a dozen web form radio buttons on a web form. Each of them is set to postback=true. However, if for instance radiobutton1 is already selected and the user selects it again, it performs...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
0
by: member | last post by:
Hi, Good day.i need some help from you guys. I'm using vb.net and sql database to build my file. The purpose of this file is to view news based on deparment. Im using listbox and radiobutton...
0
by: BizEd | last post by:
I have a textbox that fires an autopostback when filled in. The next field after the textbox is a RadioButtonList which I set focus to. The radiobutton list does have focus and activates when you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.