Just found another strange problem (maskedtextbox)

Hi there,

I have a problem which has cost me around 6 hours now. I found a quick-fix, but really have no clue, why this does not work.

OK. This is what I have done, and what works:

Say, I have a very simple Database Table with two fields: UserID and UserName.

I create a data source, edit the properties, drag and drop the dataset onto my win form, run the application and everything is fine. (All table and binding adapters are created automatically in the process). When I run the application, the window opens, the first data record is selected and I can navigate, add, delete and frolick in the sun.

This is what caused my problem:

I wanted to use a splitcontainer to have a treeview on the left and the 'form content' shown on the right. At this point I failed at adding the form (solved it later, see below), so I decided to create a crispy user control that has the same content as my previously working win form. When I now run the program, everything seems fine at first glance, except:

1. The user control does not display any data (the automatically created toolstrip seems 'disabled' until I add a data record.

2. When I restart the program, the data seems lost, although it is in the database (meaning: the user control again shows no data, the toolstrip is disabled and so on).

I _really_ would like to use User Controls as described above for my program.

This is the quick fix, which I derived at (but its ugly)

So, I went back to win forms. I used the simple form described above and added it to the container by:

Form myForm =newfrmManufacturer();
myForm.TopLevel =
false;
myForm.ShowInTaskbar =
false;
myForm.Visible =
true;
splitContainer1.Panel2.Controls.Clear();
splitContainer1.Panel2.Controls.Add(myForm);

But it looks so horrible!!! (It kinda looks like an MDI Form).

So here's my question:

Why does my User Control not work? Does this have to do with scope of some sort? Btw: It doesn't matter whether the UC is inside my project or referenced - same problem.

Any help would be greatly appreciated!

Greetings from Germany,

Michael

[2618 byte] By [MichaelBartels] at [2007-12-24]
# 1

Hi,

I have just encountered another strange problem.

When I add forms to the panel (not as top-level forms, as described above), none of my MaskedTextBoxes work anymore. I just cannot get them to receive focus. Also, with the windows form not being top-level, none of the tab orders work no more - the tab focus always moves to the treeview in the other panel.

*sigh*

I'm going to sleep now - this has been way too frustrating.

Regards,
Michael

MichaelBartels at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...