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

reopening form many times and Data Binding

P: n/a
Hello!

My question regards opening (and re-opening) Form and the Load event.

I have a main form (frmMain) and I also have a data form (frmData).

In the main form I have created:

Private fData as new frmData()

And later, as my application is running, I open data form many times (even a
hundred times) like this

fData.RowId = ... ' there exists a public property of frmData called RowId
If (fData.ShowDialog(Me) = DialogResult.OK) THEN
...
ELSE
...
ENDIF

frmData has a private object of some class called "classData" and then I
want to bind some controls on frmData to properties in classData, like this:
....
Private cData as New classData()
.....
Me.txtValue1.DataBindings.Add(New Binding("Text", cData, "Value1"))

Where can I define the binding? When I try to define it after
InitialiseComponent() I got "OutOfMemory" Exception, so I decided to move it
and do the binding during the "Load" event (as It was shown in some MSDN
Magazine articles). But it appears that the Load event fires EVERY TIME
frmData opens (contrary to what the documentation states: Load Event -
"Occurs before a form is displayed for the first time.") and the second time
my form is opened
binding fails. I could create a variable "AlreadyBound" of type Boolean but
it seems a dirty solution for me. And then again I feel creating fData every
time it is opened and the disposing of it is a waste of time and resources.

I wait for any good clues regarding:
- how to open form multiple times (this is what I do with fData)
- how to have some operations performed every time the form is opened (like
clearing the data fields) while other only the first time the form is opened
(or when it is created in the memory)
- when (and how) to do the binding

Thanks in advance. Marcin Floryan.

Nov 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Marcin,

I thought I asked you yesterday in the language.vb group what you mean with
"open" because that does not exist as far as I know, and that is just the
part not in your sample.

However I do not see that message either.

There is a show and hide and there is a way to create a form new.

Jest method robizc nowe alle nie jest do otwarte jak ja wiem.

Moze bardzo sle

:-)

Cor
Nov 22 '05 #2

P: n/a
Hi Marcin,

I thought I asked you yesterday in the language.vb group what you mean with
"open" because that does not exist as far as I know, and that is just the
part not in your sample.

However I do not see that message either.

There is a show and hide and there is a way to create a form new.

Jest method robizc nowe alle nie jest do otwarte jak ja wiem.

Moze bardzo sle

:-)

Cor
Nov 22 '05 #3

P: n/a
All I write regards VB.NET and each Form object in .NET has OpenDialog
method and has
Load event. I have no problem opening the form, or creating it. My problem
is with data binding and with strange behaviour of Open Event (contrary to
what the docs say).
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Os**************@TK2MSFTNGP11.phx.gbl...
Hi Marcin,

I thought I asked you yesterday in the language.vb group what you mean with "open" because that does not exist as far as I know, and that is just the
part not in your sample.

However I do not see that message either.

There is a show and hide and there is a way to create a form new.

Jest method robizc nowe alle nie jest do otwarte jak ja wiem.

Moze bardzo sle

:-)

Cor

Nov 22 '05 #4

P: n/a
All I write regards VB.NET and each Form object in .NET has OpenDialog
method and has
Load event. I have no problem opening the form, or creating it. My problem
is with data binding and with strange behaviour of Open Event (contrary to
what the docs say).
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Os**************@TK2MSFTNGP11.phx.gbl...
Hi Marcin,

I thought I asked you yesterday in the language.vb group what you mean with "open" because that does not exist as far as I know, and that is just the
part not in your sample.

However I do not see that message either.

There is a show and hide and there is a way to create a form new.

Jest method robizc nowe alle nie jest do otwarte jak ja wiem.

Moze bardzo sle

:-)

Cor

Nov 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.