By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,572 Members | 963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,572 IT Pros & Developers. It's quick & easy.

Resetting combo boxes

P: n/a
Ant
Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads, the
combo box is popluated using a method containing the simple code below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm, selection..
from the combo box, I want the combo box to reset the selection when they hit
the enter button. I use the same method above to do this, however their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box is
set as A. Usr chooses C. After above method is run, I want combo again to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant

Feb 13 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Use ComboBox.SelectedItem or ComboBox.SelectedIndex to reset the comboBox
selection.

e.g.
cboDepartment.SelectedItem = "My Dept";
or
cboDepartment.SelectedIndex = 0; // 0 = first listitem, -1 = no item is
selected

BTW, do you really need to rebind the data for every 'Enter' key?

"Ant" wrote:
Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads, the
combo box is popluated using a method containing the simple code below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm, selection..
from the combo box, I want the combo box to reset the selection when they hit
the enter button. I use the same method above to do this, however their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box is
set as A. Usr chooses C. After above method is run, I want combo again to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant

Feb 13 '06 #2

P: n/a
Ant
Hi Tedmond,

Thanks for your advice. I'm using the index to refresh it now as suggested.
Cheers. As for binding with every entry; This was just an attempt at
refreshing the combo boxes. I'll be moving that out of the button now. Thanks
for your advice though.

Much appreciated.
Ant

"Tedmond" wrote:
Use ComboBox.SelectedItem or ComboBox.SelectedIndex to reset the comboBox
selection.

e.g.
cboDepartment.SelectedItem = "My Dept";
or
cboDepartment.SelectedIndex = 0; // 0 = first listitem, -1 = no item is
selected

BTW, do you really need to rebind the data for every 'Enter' key?

"Ant" wrote:
Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads, the
combo box is popluated using a method containing the simple code below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm, selection..
from the combo box, I want the combo box to reset the selection when they hit
the enter button. I use the same method above to do this, however their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box is
set as A. Usr chooses C. After above method is run, I want combo again to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant

Feb 13 '06 #3

P: n/a
I have been trying to clear combobox settings in Access 2003 w/o success. I
was hoping what you stated here would work but it doesn't. It seens that
Access doesn't support .selectedItem or .SelectedIndex. Am I missing
somingthing?? As I'm really stuck.

I am assinging values to comboboxes either from a query row source or a mix
of user inputs which builds dynamic queries statements from the resultant
entries. The problem arrises when I select a numberic values for one query
and then a text value for the same CB w/o closing the form. I get a message
that the value entered is not valid. The only way I can get the CB to work
correctly again is to close the form and restart it.

Any advise would be greatly appreciated.
--
Mike

"Tedmond" wrote:
Use ComboBox.SelectedItem or ComboBox.SelectedIndex to reset the comboBox
selection.

e.g.
cboDepartment.SelectedItem = "My Dept";
or
cboDepartment.SelectedIndex = 0; // 0 = first listitem, -1 = no item is
selected

BTW, do you really need to rebind the data for every 'Enter' key?

"Ant" wrote:
Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads, the
combo box is popluated using a method containing the simple code below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm, selection..
from the combo box, I want the combo box to reset the selection when they hit
the enter button. I use the same method above to do this, however their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box is
set as A. Usr chooses C. After above method is run, I want combo again to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant

Mar 15 '07 #4

P: n/a
Try setting combobox.SelectedIndex to -1.

This is a .Net programming newsgroup. If that answer doesn't work, try
posting your question to a Microsoft Access newsgroup.

Robin S.
-------------------------------
"Mike Samyn" <Mi*******@discussions.microsoft.comwrote in message
news:A5**********************************@microsof t.com...
>I have been trying to clear combobox settings in Access 2003 w/o success.
I
was hoping what you stated here would work but it doesn't. It seens
that
Access doesn't support .selectedItem or .SelectedIndex. Am I missing
somingthing?? As I'm really stuck.

I am assinging values to comboboxes either from a query row source or a
mix
of user inputs which builds dynamic queries statements from the resultant
entries. The problem arrises when I select a numberic values for one
query
and then a text value for the same CB w/o closing the form. I get a
message
that the value entered is not valid. The only way I can get the CB to
work
correctly again is to close the form and restart it.

Any advise would be greatly appreciated.
--
Mike

"Tedmond" wrote:
>Use ComboBox.SelectedItem or ComboBox.SelectedIndex to reset the
comboBox
selection.

e.g.
cboDepartment.SelectedItem = "My Dept";
or
cboDepartment.SelectedIndex = 0; // 0 = first listitem, -1 = no item is
selected

BTW, do you really need to rebind the data for every 'Enter' key?

"Ant" wrote:
Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads,
the
combo box is popluated using a method containing the simple code
below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm,
selection..
from the combo box, I want the combo box to reset the selection when
they hit
the enter button. I use the same method above to do this, however
their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box
is
set as A. Usr chooses C. After above method is run, I want combo again
to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant

Mar 16 '07 #5

P: n/a
Robin,

No such property in Access. I will try thier group directly.

Thanks just the same.

--
Mike
"RobinS" wrote:
Try setting combobox.SelectedIndex to -1.

This is a .Net programming newsgroup. If that answer doesn't work, try
posting your question to a Microsoft Access newsgroup.

Robin S.
-------------------------------
"Mike Samyn" <Mi*******@discussions.microsoft.comwrote in message
news:A5**********************************@microsof t.com...
I have been trying to clear combobox settings in Access 2003 w/o success.
I
was hoping what you stated here would work but it doesn't. It seens
that
Access doesn't support .selectedItem or .SelectedIndex. Am I missing
somingthing?? As I'm really stuck.

I am assinging values to comboboxes either from a query row source or a
mix
of user inputs which builds dynamic queries statements from the resultant
entries. The problem arrises when I select a numberic values for one
query
and then a text value for the same CB w/o closing the form. I get a
message
that the value entered is not valid. The only way I can get the CB to
work
correctly again is to close the form and restart it.

Any advise would be greatly appreciated.
--
Mike

"Tedmond" wrote:
Use ComboBox.SelectedItem or ComboBox.SelectedIndex to reset the
comboBox
selection.

e.g.
cboDepartment.SelectedItem = "My Dept";
or
cboDepartment.SelectedIndex = 0; // 0 = first listitem, -1 = no item is
selected

BTW, do you really need to rebind the data for every 'Enter' key?

"Ant" wrote:

Hi, (Winform VS2003)
I have a combo box bound to a typed data set. When the form loads,
the
combo box is popluated using a method containing the simple code
below:

------------------------
// Fill the datasets for the combo boxes
daDepartment.Fill(dsDepartment.Departments);

// Refresh the combo box
cboDepartment.Refresh();
------------------------------

This works fine, however, once the user has selected a, ummm,
selection..
from the combo box, I want the combo box to reset the selection when
they hit
the enter button. I use the same method above to do this, however
their
selection is reatained & is shown as the current selection.
In other words If there is Selection A, B, C, D. On load the combo box
is
set as A. Usr chooses C. After above method is run, I want combo again
to
display A. This is not currently happening. C remains.

Hope somwone can shed some light on this seemingly simple problem.
Many thanks in advance.
Ant



Mar 16 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.