Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Custom Control inheriting from a Custom Control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cyr1dian - 26 Oct 2007 14:57 GMT
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
Peter Duniho - 26 Oct 2007 18:04 GMT
In article
<1193407069.523739.97220@y42g2000hsy.googlegroups.com>Cyr1dian
>  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

Signature

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

Cyr1dian - 29 Oct 2007 08:35 GMT
First thing I though of too ;)

I tried BrinToFront() and Visible=true at runtime, but to no avail.
Peter Duniho - 29 Oct 2007 09:11 GMT
> 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
Cyr1dian - 29 Oct 2007 10:25 GMT
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
Peter Duniho - 29 Oct 2007 18:36 GMT
> [...]
> Thanks for you help anyway ;)

You're welcome...even if all I did was ask a dumb question.  :)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.