Custom Control inheriting from a Custom Control

Custom Control inheriting from a Custom Control

Post by Cyr1dia » Sat, 27 Oct 2007 22:57:49


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
 
 
 

Custom Control inheriting from a Custom Control

Post by Peter Duni » Sun, 28 Oct 2007 02:04:48

In article
< XXXX@XXXXX.COM >Cyr1dian


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

--
I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.yqcomputer.com/

 
 
 

Custom Control inheriting from a Custom Control

Post by Q3lyMWRpYW » Tue, 30 Oct 2007 16:35:01

First thing I though of too ;)

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

Custom Control inheriting from a Custom Control

Post by Peter Duni » Tue, 30 Oct 2007 17:11:20

On 2007-10-29 00:35:01 -0700, Cyr1dian
< XXXX@XXXXX.COM > said:


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
 
 
 

Custom Control inheriting from a Custom Control

Post by Q3lyMWRpYW » Tue, 30 Oct 2007 18:25:00

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