Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. General Coding and Design => Calculator Programming
Author Message
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 25 Jul 2009 03:54:34 pm    Post subject:

How can I pass all of an objects properties through a procedure in a variable in C#? For instance, I want to send a panels properties through a procedure to set width, height, etc. depending on which panel it is.
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 25 Jul 2009 06:38:24 pm    Post subject:

I've never used C#, but if I'm understanding what you're asking, I think you want to pass a reference to the object to the procedure, and then the procedure can modify any of the object's properties.
Back to top
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 25 Jul 2009 06:58:45 pm    Post subject:

magicdanw wrote:
I've never used C#, but if I'm understanding what you're asking, I think you want to pass a reference to the object to the procedure, and then the procedure can modify any of the object's properties.



Yup that's what I was talking about.
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 25 Jul 2009 07:47:35 pm    Post subject:

So did that help? Razz
Back to top
benryves


Active Member


Joined: 23 Feb 2006
Posts: 564

Posted: 25 Jul 2009 08:19:43 pm    Post subject:

Your question doesn't really make much sense at the moment. magicdanw's suggestion sounds the closest, ie:


Code:
void SetProperties(Panel p) {
   p.Width = 100;
   p.Height = 200;
}
Back to top
DigiTan
Unregistered HyperCam 2


Super Elite (Last Title)


Joined: 10 Nov 2003
Posts: 4468

Posted: 25 Jul 2009 09:19:29 pm    Post subject:

Is this called inheritance? (I really gotta start taking code tutorials)
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 25 Jul 2009 09:22:24 pm    Post subject:

Not at all...it's a basic technique of object-oriented languages.
Back to top
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 25 Jul 2009 10:05:05 pm    Post subject:

Sorry, I'll try to clarify more. I have two separate panels that represent planes to draw a graph on. In the code below there are two functions that look the same except they are for painting on the two separate graphs; one for the first one and one for the second. What I need to be able to do is send a variable or object through that would have all the properties of the panel so I can set the width etc no matter which panel it was using only one variable in the paintGraph function. I don't want to waste time with Tags if there is another way to do this because I could use a lot less code if there was away to use just an object or variable being sent through the procedure. So there would be a third argument in the function that would represent either the object or variable being passed with the objects properties.



Code:
    private void pnlFirstGraph_Paint(object sender, PaintEventArgs e)
    {
        paintGraph(sender, e);
    }

    private void pnlSecondGraph_Paint(object sender, PaintEventArgs e)
    {
        paintGraph(sender, e);
    }
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 26 Jul 2009 09:29:37 pm    Post subject:

If the code of pnlFirstGraph_Paint and pnlSecondGraph_Paint is exactly the same, why do you need two of them?
Back to top
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 26 Jul 2009 09:39:16 pm    Post subject:

Because they are two different panels calling the paint function separately, which just happens to lead to the same function to actually draw on them. When the form is refreshed and needs to be redrawn these two functions will be called.


EDIT: Never mind. This issue was solved.


Last edited by Guest on 26 Jul 2009 10:00:49 pm; edited 1 time in total
Back to top
benryves


Active Member


Joined: 23 Feb 2006
Posts: 564

Posted: 27 Jul 2009 09:50:35 am    Post subject:

You can attach the same event handler to multiple event sources, you don't need to create a new event handler for each one (rather than double-clicking in the event property editor, pick an existing handler in the drop-down).
Back to top
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 27 Jul 2009 10:43:48 am    Post subject:

benryves wrote:
You can attach the same event handler to multiple event sources, you don't need to create a new event handler for each one (rather than double-clicking in the event property editor, pick an existing handler in the drop-down).


Yeah I realized that after I made the last post. With two event handlers it didn't seem to make a huge benefit, but if I ever decided to add more that do the same then you way is in fact a lot better.
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 

Advertisement