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

Refresh form / form controls in backdrop?

P: n/a
Hey there all,

Fairly easy question for a C# expert, i assume! Am still working on my Photo
Album.

On frmBrowsePhotos, i have a listBox (photosList) containing photoID's from
a table in an Access Database. I click 'Add Photo' on that form and after
the OpenFileDialog (etc.), it asks me to save some information about the
photo (caption etc.) on a new form (frmAddPhotoInfo) opened up in front of
the previous (frmBrowsePhotos).

On frmAddPhotoInfo, when i hit the OK button to confirm the new photo and
it's information - i want the ListBox to be refreshed in the background to
display the new photoID.

Basically, i want to refresh that form (frmBrowsePhotos) and / or repopulate
that ListBox (listPhotos)?

Many thanks in advance.

Brian


Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hey Brian,

Could you please elaborate on what you mean by saying 'refresh in the
background'?
You can for example run a query against the database on a worker thread or
by using BeginInvoke on a delegate, but everything you do to the form and
the controls should happen on the UI thread.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Brian Basquille" <re**********@please.com> wrote in message
news:uq**************@TK2MSFTNGP10.phx.gbl...
Hey there all,

Fairly easy question for a C# expert, i assume! Am still working on my
Photo Album.

On frmBrowsePhotos, i have a listBox (photosList) containing photoID's
from a table in an Access Database. I click 'Add Photo' on that form and
after the OpenFileDialog (etc.), it asks me to save some information about
the photo (caption etc.) on a new form (frmAddPhotoInfo) opened up in
front of the previous (frmBrowsePhotos).

On frmAddPhotoInfo, when i hit the OK button to confirm the new photo and
it's information - i want the ListBox to be refreshed in the background to
display the new photoID.

Basically, i want to refresh that form (frmBrowsePhotos) and / or
repopulate that ListBox (listPhotos)?

Many thanks in advance.

Brian


Nov 16 '05 #2

P: n/a
Dmitriy,

Thanks for the response. I don't think what i require would be as
complicated as what you've suggested.

Basically, it involves two forms - BrowsePhotos and AddNewPhotoInfo.

When i choose to add a 'New Photo' on the BrowsePhotos form, the user
chooses the photo and AddNewPhotoInfo form then pops up to allow the user to
enter information about the photo to be recorded (Caption etc.). All this
time however, the BrowsePhotos form remains in the background showing all
the existing photo id's (listPhotos) in the database.

When the user presses the 'OK' on the AddNewInfo form, a SQL statement is
executed to save the new Photo information (and a unique ID to the
database). However, i need to exit the BrowsePhotos form and launch it again
for it to reflect the newly added photo (and it's id) in the listPhotos
ListBox.

All i basically require is when the user pressed 'OK' on the
AddNewPhotoForm, the listPhotos listBox is automatically refreshed on the
BrowsePhotos form.

I could presumably make the listPhotos public and use something along the
lines of:

BrowsePhotos browsePhotos = new BrowsePhotos();
browsePhotos.listPhotos.Refresh();
browsePhotos.Show();

But the problem with that is i want it to update on the existing
BrowsePhotos form.. and not create a new form.

Hope this clarifies my problem a bit more!

Brian

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:Op****************@TK2MSFTNGP09.phx.gbl...
Hey Brian,

Could you please elaborate on what you mean by saying 'refresh in the
background'?
You can for example run a query against the database on a worker thread or
by using BeginInvoke on a delegate, but everything you do to the form and
the controls should happen on the UI thread.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Brian Basquille" <re**********@please.com> wrote in message
news:uq**************@TK2MSFTNGP10.phx.gbl...
Hey there all,

Fairly easy question for a C# expert, i assume! Am still working on my
Photo Album.

On frmBrowsePhotos, i have a listBox (photosList) containing photoID's
from a table in an Access Database. I click 'Add Photo' on that form and
after the OpenFileDialog (etc.), it asks me to save some information
about the photo (caption etc.) on a new form (frmAddPhotoInfo) opened up
in front of the previous (frmBrowsePhotos).

On frmAddPhotoInfo, when i hit the OK button to confirm the new photo and
it's information - i want the ListBox to be refreshed in the background
to display the new photoID.

Basically, i want to refresh that form (frmBrowsePhotos) and / or
repopulate that ListBox (listPhotos)?

Many thanks in advance.

Brian

Nov 16 '05 #3

P: n/a
Brian,
All i basically require is when the user pressed 'OK' on the
AddNewPhotoForm, the listPhotos listBox is automatically refreshed on the
BrowsePhotos form.
I assume you have a button 'Add new photo' on frmBrowsePhotos.

In this case, in the button's Click handler, you should first launch the
'Add new photo' form in the modal mode.
After the user closes the frmAddNewInfo, provided the DialogResult is OK,
you ask the frmAddNewInfo instance for the photo file name and ID given (you
will need to add a couple of public properties to frmAddNewInfo for that).
Then, as the control flow has returned to the Click event handler which is a
part of frmBrowsePhotos, we can now just add a new item to the listbox.

In pseudocode

void cmdAddNew_Click(object sender, EventArgs e)
{
frmAddNewInfo newForm = new frmAddNewInfo();
DialogResult result = frmAddNewInfo.ShowModal();
if (DialogResult.OK == result)
{
listBox.AddPhotoItem(newForm.ID, newForm.FileName);
}

newForm.Dispose();
}

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Brian Basquille" <re**********@please.com> wrote in message
news:ON*****************@TK2MSFTNGP09.phx.gbl... Dmitriy,

Thanks for the response. I don't think what i require would be as
complicated as what you've suggested.

Basically, it involves two forms - BrowsePhotos and AddNewPhotoInfo.

When i choose to add a 'New Photo' on the BrowsePhotos form, the user
chooses the photo and AddNewPhotoInfo form then pops up to allow the user
to enter information about the photo to be recorded (Caption etc.). All
this time however, the BrowsePhotos form remains in the background showing
all the existing photo id's (listPhotos) in the database.

When the user presses the 'OK' on the AddNewInfo form, a SQL statement is
executed to save the new Photo information (and a unique ID to the
database). However, i need to exit the BrowsePhotos form and launch it
again for it to reflect the newly added photo (and it's id) in the
listPhotos ListBox.

All i basically require is when the user pressed 'OK' on the
AddNewPhotoForm, the listPhotos listBox is automatically refreshed on the
BrowsePhotos form.

I could presumably make the listPhotos public and use something along the
lines of:

BrowsePhotos browsePhotos = new BrowsePhotos();
browsePhotos.listPhotos.Refresh();
browsePhotos.Show();

But the problem with that is i want it to update on the existing
BrowsePhotos form.. and not create a new form.

Hope this clarifies my problem a bit more!

Brian

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:Op****************@TK2MSFTNGP09.phx.gbl...
Hey Brian,

Could you please elaborate on what you mean by saying 'refresh in the
background'?
You can for example run a query against the database on a worker thread
or by using BeginInvoke on a delegate, but everything you do to the form
and the controls should happen on the UI thread.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Brian Basquille" <re**********@please.com> wrote in message
news:uq**************@TK2MSFTNGP10.phx.gbl...
Hey there all,

Fairly easy question for a C# expert, i assume! Am still working on my
Photo Album.

On frmBrowsePhotos, i have a listBox (photosList) containing photoID's
from a table in an Access Database. I click 'Add Photo' on that form and
after the OpenFileDialog (etc.), it asks me to save some information
about the photo (caption etc.) on a new form (frmAddPhotoInfo) opened up
in front of the previous (frmBrowsePhotos).

On frmAddPhotoInfo, when i hit the OK button to confirm the new photo
and it's information - i want the ListBox to be refreshed in the
background to display the new photoID.

Basically, i want to refresh that form (frmBrowsePhotos) and / or
repopulate that ListBox (listPhotos)?

Many thanks in advance.

Brian



Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.