Click here to Skip to main content
15,892,674 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do I get the correct font height in Hindi fonts? Pin
Nagy Vilmos28-Jul-09 23:10
professionalNagy Vilmos28-Jul-09 23:10 
GeneralRe: How do I get the correct font height in Hindi fonts? Pin
Gywox28-Jul-09 23:20
Gywox28-Jul-09 23:20 
Questionhorizontal scroll bar move event... Pin
spalanivel28-Jul-09 21:21
spalanivel28-Jul-09 21:21 
AnswerRe: horizontal scroll bar move event... Pin
stancrm28-Jul-09 21:43
stancrm28-Jul-09 21:43 
GeneralRe: horizontal scroll bar move event... Pin
spalanivel28-Jul-09 22:00
spalanivel28-Jul-09 22:00 
GeneralRe: horizontal scroll bar move event... Pin
spalanivel29-Jul-09 0:53
spalanivel29-Jul-09 0:53 
AnswerRe: horizontal scroll bar move event... Pin
Alan N29-Jul-09 2:03
Alan N29-Jul-09 2:03 
QuestionOOP approach, static method Pin
Raybarg28-Jul-09 20:46
professionalRaybarg28-Jul-09 20:46 
Cutting right into my host of questions, here is a crackdown of my class:
class TheDocument
{
    private TheData[] _list;

    public TheDocument(TheData[] list)
    {
        _list = list;
    }

    public static void Print(TheData[] list)
    {
        TheDocument d = new TheDocument(list);
        PrintDocument pd = new PrintDocument();
        pd.PrintPage += new PrintPageEventHandler(d.PrintPage);
        pd.Print();
    }

    private void PrintPage(object sender, PrintPageEventArgs ev)
    {
        // Printing code...
    }
}


Explaining above code, I came to decide that I need no multiple instances of this document-printing class so I made static Print() method which will initialize the instance and does the trick. So from my application I can just call TheDocument.Print(...); and nothing else.

The question is, I couldnt find a way to pass around TheData[] array in other way than either trough constructor or after construction setting it to the instance of an object. This is where all my questions start to roam and I find myself a bit off track; This static method is instance of the calling instance? So within new TheDocument instance I have no access to it without reference?



All the printing stuff is merely serving as an example. My real world solution will inherit from more robust printing class and only contain the code for a specific type of document. I know theres plenty of 3rd party solutions for document designing and using them to print, but I will have host of different types of "simple list" kind of documents to print and decided to take this brute approach.

Coming from VB and C(embedded) programming all this OOP and fancy C# stuff are so overwhelming Wink | ;) Feels like I need proper OOP course or something since I dont even know if there is a term to call class with static method which will make instance of the class itself in it. Or if the whole class is static, is there a name for it instead of saying "static class". Another question about OOP I would ask is if I have alot of variables or properties in one object and define new object in it, what is the best way of accessing those variables or properties. Handing out reference to "parent" object kind of makes that approach less encapsulated?
AnswerRe: OOP approach, static method Pin
Christian Graus28-Jul-09 21:00
protectorChristian Graus28-Jul-09 21:00 
AnswerRe: OOP approach, static method Pin
DaveyM6928-Jul-09 22:41
professionalDaveyM6928-Jul-09 22:41 
GeneralRe: OOP approach, static method Pin
Raybarg28-Jul-09 23:04
professionalRaybarg28-Jul-09 23:04 
GeneralRe: OOP approach, static method Pin
DaveyM6928-Jul-09 23:39
professionalDaveyM6928-Jul-09 23:39 
AnswerRe: OOP approach, static method Pin
PIEBALDconsult29-Jul-09 4:58
mvePIEBALDconsult29-Jul-09 4:58 
QuestionAttach User Entered Data with word Document while saving Pin
mandar77728-Jul-09 20:41
mandar77728-Jul-09 20:41 
QuestionTreeView NodeMouseHover Event Pin
vhassan28-Jul-09 20:15
vhassan28-Jul-09 20:15 
QuestionDisplay Image from Path Pin
nudma28-Jul-09 19:47
nudma28-Jul-09 19:47 
AnswerRe: Display Image from Path Pin
Christian Graus28-Jul-09 20:10
protectorChristian Graus28-Jul-09 20:10 
AnswerRe: Display Image from Path Pin
Blikkies28-Jul-09 20:14
professionalBlikkies28-Jul-09 20:14 
GeneralRe: Display Image from Path Pin
nudma28-Jul-09 21:15
nudma28-Jul-09 21:15 
GeneralRe: Display Image from Path Pin
Blue_Boy29-Jul-09 0:45
Blue_Boy29-Jul-09 0:45 
GeneralRe: Display Image from Path Pin
Blikkies29-Jul-09 1:32
professionalBlikkies29-Jul-09 1:32 
GeneralRe: Display Image from Path Pin
nudma29-Jul-09 4:08
nudma29-Jul-09 4:08 
GeneralRe: Display Image from Path Pin
Blue_Boy29-Jul-09 7:38
Blue_Boy29-Jul-09 7:38 
GeneralRe: Display Image from Path Pin
Blikkies29-Jul-09 8:26
professionalBlikkies29-Jul-09 8:26 
AnswerRe: Display Image from Path Pin
Blue_Boy28-Jul-09 20:23
Blue_Boy28-Jul-09 20:23 

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.