473,320 Members | 2,073 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,320 software developers and data experts.

Resetting combo boxes

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

Similar topics

1
by: FZ | last post by:
Hi Gang, I was wondering if a generous person might be able to walk me through what I believe is a pretty simple task. I actually have significant Access experience, but I haven't done it in...
1
by: Anonymous | last post by:
Quick question - I have a form with with many fields on it. I have three combo boxes that are used as search engines (Last Name, City, State). For example, when I open the form, all three search...
0
by: Krisa | last post by:
Hello all, I just discovered something (stop me if you've heard this before....) that was causing me a significant performance hit when opening a form with subforms. To speed up loading the...
0
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number...
4
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. ...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
1
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a...
2
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once...
2
by: someshbakliwal | last post by:
Hi, I have created some autopopulating combo boxes on my HTML page (script- Javascript). so these combo boxes are autopopulated with choices made in previous combo boxes. The problem I am facing is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.