Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: source code PinPopular
Not Active16-Feb-11 14:47
mentorNot Active16-Feb-11 14:47 
GeneralRe: source code Pin
om_metab17-Feb-11 12:36
om_metab17-Feb-11 12:36 
GeneralRe: source code Pin
Not Active17-Feb-11 13:27
mentorNot Active17-Feb-11 13:27 
Questionabstract, override and the Visual Studio Designer Pin
Dewald15-Feb-11 21:52
Dewald15-Feb-11 21:52 
AnswerRe: abstract, override and the Visual Studio Designer Pin
Luc Pattyn16-Feb-11 0:47
sitebuilderLuc Pattyn16-Feb-11 0:47 
JokeRe: abstract, override and the Visual Studio Designer Pin
Wayne Gaylard16-Feb-11 1:17
professionalWayne Gaylard16-Feb-11 1:17 
GeneralRe: abstract, override and the Visual Studio Designer Pin
Luc Pattyn16-Feb-11 1:57
sitebuilderLuc Pattyn16-Feb-11 1:57 
GeneralRe: abstract, override and the Visual Studio Designer Pin
Dewald16-Feb-11 1:56
Dewald16-Feb-11 1:56 
Thanks Luc, number 2 is what I have been doing so far but it is more tiresome than one might think - which is why I decided I need to make a plan and find a better way of doing this.

I can't just drop the abstract keyword because the section of code that calls the overridden methods doesn't know which TabPage it is accessing. It does something like this:
(TabPage_First as TabPageTemplate).Process()

which means that TabPageTemplate must have a Process() method and it must be overridden by TabPage_First (and all the other TabPages that implement TabPageTemplate).

I can however have TabPage_First inherit from TabPage as opposed to TabPageTemplate, then open it in Designer and do what I want to do, after which I change the inheritance back to TabPageTemplate again. It's a little bit of hassle but nothing as bad as the way I used to do it.

HOWEVER, once I did that I made another unpleasant discovery. You can't use Designer to design the visual layout of controls on a TabPage if the TabPage isn't inside a TabControl. All it shows is a list of all the controls on the TabPage but not positioned on the screen as their properties dictate. You can change their properties (size, location, etc.) but it doesn't show on the TabPage in Designer, you only see it once you compile and run the application.

So here's what I ended up doing, just in case anyone else is interested;

In stead of the TabPageTemplate as described above I defined a UserControlTemplate as follows:
public abstract partial class UserControlTemplate : UserControl
    {
        public abstract void Process();
        public abstract void Cancel();
        public abstract bool LoseFocus();
        public abstract void Populate(int identifier);
        public abstract event EventHandler PageClosed;
    }


I then design various UserControls, all of which implement the above abstract UserControlTemplate. At runtime I then create a new empty TabPage, add this UserControl (let's say I call it UserControl_First) to the TabPage, set its Dock value to Fill and then add that TabPage to the TabControl.

I still have to change the inheritance of the UserControl_First from UserControlTemplate to UserControl in order to edit it in Designer and back to UserControlTemplate before compiling but other than that little hassle it works like a charm.
AnswerRe: abstract, override and the Visual Studio Designer Pin
Luc Pattyn16-Feb-11 2:04
sitebuilderLuc Pattyn16-Feb-11 2:04 
GeneralRe: abstract, override and the Visual Studio Designer Pin
Dewald16-Feb-11 2:37
Dewald16-Feb-11 2:37 
GeneralRe: abstract, override and the Visual Studio Designer Pin
Luc Pattyn16-Feb-11 2:51
sitebuilderLuc Pattyn16-Feb-11 2:51 
GeneralRe: abstract, override and the Visual Studio Designer Pin
Dewald16-Feb-11 4:05
Dewald16-Feb-11 4:05 
AnswerRe: abstract, override and the Visual Studio Designer Pin
PIEBALDconsult16-Feb-11 1:48
mvePIEBALDconsult16-Feb-11 1:48 
GeneralRe: abstract, override and the Visual Studio Designer Pin
Dewald16-Feb-11 2:02
Dewald16-Feb-11 2:02 
QuestionWrite contents of dataset into email Pin
<<Tash18>>15-Feb-11 18:56
<<Tash18>>15-Feb-11 18:56 
AnswerRe: Write contents of dataset into email Pin
Hum Dum15-Feb-11 20:07
Hum Dum15-Feb-11 20:07 
GeneralRe: Write contents of dataset into email Pin
<<Tash18>>15-Feb-11 20:13
<<Tash18>>15-Feb-11 20:13 
GeneralRe: Write contents of dataset into email Pin
Hum Dum15-Feb-11 20:15
Hum Dum15-Feb-11 20:15 
GeneralRe: Write contents of dataset into email Pin
<<Tash18>>15-Feb-11 20:27
<<Tash18>>15-Feb-11 20:27 
GeneralRe: Write contents of dataset into email Pin
<<Tash18>>15-Feb-11 21:39
<<Tash18>>15-Feb-11 21:39 
GeneralRe: Write contents of dataset into email Pin
Hum Dum15-Feb-11 21:55
Hum Dum15-Feb-11 21:55 
AnswerRe: Write contents of dataset into email Pin
Luc Pattyn16-Feb-11 0:50
sitebuilderLuc Pattyn16-Feb-11 0:50 
AnswerRe: Write contents of dataset into email Pin
PIEBALDconsult16-Feb-11 1:51
mvePIEBALDconsult16-Feb-11 1:51 
Questionget relative path Pin
igalep13215-Feb-11 12:18
igalep13215-Feb-11 12:18 
AnswerRe: get relative path [modified] Pin
Luc Pattyn15-Feb-11 12:38
sitebuilderLuc Pattyn15-Feb-11 12:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.