Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hello,

I have a Problem:

In my MainWindows I can easy access the Control - it ist simply "this".

In my MainWindow I use a Class DrawingUtils an this class use other classes like Figure, witch should be draw:

 
class Figure
public void Draw (Control control)
{Rectangle destination = new Rectangle(0,0,96,96);
destination.Location=control.PointToScreen(new Point(360,360));
.
.
.
class DrawingUtils
private void CreateSurfaces(Control control)
{
_display = new Device(); 
_display.SetCooperativeLevel(control, CooperativeLevelFlags.Normal);

 

How can I access the Control from my Mainwindow in a Class? I do not want to use Parameters like "(Control control)".

Is there a way to access it from those classes?

Thank You a lot,

Roman

Edited by romanhoehne
Posted

Usually, when I want to do something like this, I declare the forms in a Module. I don't instanciate them... just declare...

 

Module Forms
    
    Dim FormMain as System.Windows.Forms.Form

    'This will start the app with this form...
    Public Sub Main
         Application.Run(New FormMain)
    End Sub

End Module

'If you have a class in this project and want to access the objects on the FormMain you just have to call this:
'Lets assume you want to access a TextBox on thet Form called TextBox1...
MessageBox.Show(Forms.FormMain.TextBox1.Text)

 

Alex :D

Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...