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

C# 3.0 2008 Win Form Combo Box Runtime Adding

47
HI guys,

I am developing a winform and need to update the contents of a combo box at runtime. I currently click a button that brings up a new dialog and click save. I then return to the parent form and at that point i rebind the combo box to the collection that retrieves my new saved item from the DB. Problem is that i can see the item when I debug and step through but the combo box has not been refreshed to show the new item.

Expand|Select|Wrap|Line Numbers
  1.         public void BindSuppliers()
  2.         {
  3.             string strConnection = string.Empty;
  4.  
  5.             try
  6.             {
  7.                 SupplierCollection oCollection = Data.GetSuppliers(strConnection);
  8.  
  9.                 ddlSuppliers.Items.Clear();
  10.  
  11.                 ddlSuppliers.DataSource  = oCollection;
  12.  
  13.                 ddlSuppliers.DisplayMember = "SupplierName";
  14.                 ddlSuppliers.ValueMember = "SupplierId";
  15.             }
  16.             catch
  17.             {
  18.                 // log 
  19.             }
  20.         }
  21.  
  22.         private void btnSave_Click(object sender, EventArgs e)
  23.         {
  24.             Supplier s = new Supplier();
  25.  
  26.             try
  27.             {
  28.                 s.SupplierName = txtSupplier.Text;
  29.                 Data.AddSupplier(s);
  30.                 CloseForm();
  31.             }
  32.             catch (Exception oEx)
  33.             {
  34.                 // log
  35.             }
  36.         }
  37.  
  38.         private void CloseForm()
  39.         {
  40.             Form1 f = new Form1();
  41.  
  42.             try
  43.             {
  44.                 f.BringToFront();
  45.                 f.BindSuppliers();
  46.                 this.Close();
  47.             }
  48.             catch (Exception oEx)
  49.             {
  50.                 // log
  51.             }
  52.         }
  53.  
May 2 '08 #1
0 1022

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: kk | last post by:
Have 2 problems, any help is appreciated. Tab with Grids -------------- BL - fetching data from DB ( 5 secs - 10 rows) Grid Laod - 20 secs Grid Paint on tab change - 20 secs Problem: The...
1
by: kk | last post by:
I have 2 issues, please help ! 1st issue : -------------------------------------------------------- Loading Grid ------------ 1) creating new rows in a datatable and adding data a array...
4
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record...
4
by: jcazmail-groups | last post by:
I have a child form that has a combo box whose underlying query needs to be filtered by a value from a combo box on the parent form. I have succeeded in doing this by putting the following SQL in...
0
by: Craig G | last post by:
how would i go about entering a blankitem into a combo box that resides in the footer of a Datagrid at runtime? the combo is already being populated on the page load using the prerender event. ...
2
by: Nikolay Petrov | last post by:
I have asked a question before some time, and a guy responded to it. His answer raised new questions and I replied them back, but still no answer. I need them urgently so I am to post the whole...
7
by: ewarts | last post by:
Hello all, I'm having an issue adding more combo box to an existing form, please correct me if I'm wrong in my method but i'm copying the combo box above and pasting it below so to have the same...
6
by: =?Utf-8?B?amVmZmVyeQ==?= | last post by:
i need help with a combo box and this same code works on my first tab with a combo box. The error or problem i have is this code causes an index out of range error when i run it on my second combo...
8
Megalog
by: Megalog | last post by:
Hey guys.. my turn to ask a question: I'm having a weird issue with a form I've reworked. This form has a combo box, which when used is changing the recordsource of a subform. This subform has...
0
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.