Custom Control inheriting from a Custom Control

C

Cyr1dian

Hi,

My problem is that a custom control "newA" that inherits from a base
custom control "baseA" is not displaying any contained controls - that
were not inherited - at run time, but displays them fine at design
time.

I'll give a short example:

public class baseA: UserControl
{
//add datagrid in designer and set some properties.
}

public class newA: baseA
{
//add a second grid and some buttons next to the existing datagrid in
the deisgner.
//programatically load second grid with data depending on records
selected on the first grid
}

public class main
{
//I put the newA control on my form programatically
}

What happens:
Altough newA looks fine in the designer when the program is run only
the grid from baseA shows up. I found that the controls are actually
present and working after setting a breakpoint; they are simply not
visible (the visible property is true of course).

Additional information:
My base class is not abstract because then the designer doens't work
anymore (makes sense, just not handy). The inherited controls
contained within the base are perfectly usable when designing newA.
The grid from the base is fully functional.

I have found people having similair problem but no solutions.

All help is appreciated.

grtz,
Cyr
 
P

Peter Duniho

My problem is that a custom control "newA" that inherits from a base
custom control "baseA" is not displaying any contained controls -
thatwere not inherited - at run time, but displays them fine at
design time. [...]

Possibly a dumb question, but...could it be a z-order problem? With
the grid added in baseA obscuring the controls added by the derived
class?

Pete
 
G

Guest

First thing I though of too ;)

I tried BrinToFront() and Visible=true at runtime, but to no avail.
 
P

Peter Duniho

First thing I though of too ;)

I tried BrinToFront() and Visible=true at runtime, but to no avail.

Well, since it did turn out to be a dumb question, here's the standard
advice: post a concise-but-complete sample of code that reliably
reproduces the problem.

Given that you got no other replies, I suspect that's your best hope of
getting some useful information.

Pete
 
G

Guest

Hi Pete,

It turned out to be my bad. When adding the control to the main form there
was some old code that didn't use the newer parts of the control.

Sorry for wasting your time. I found it entirely by luck though when
substituting my baseclass with an interface (to work around my problem) I
noticed the baseclass wasn't handled well by the control insertion code. What
added to the confusion was the fact that I could see all the controls I
needed in memory (makes sense afterwards) and some people did have similair
problems to mine (although I'm guessing with a different cause).

Thanks for you help anyway ;)

Grtz,
Cyr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top