Ed King
Ed King

Reputation: 1863

Actioning a C# GUI from beneath

I have inherited a C# GUI that I need to make some changes to. The main thing I need to do is to action the view controllers to fill in forms and things automatically and without a user.

Being very new to C#, is it possible to initialise GUI elements and event handlers so that they are valid objects without actually displaying them on the screen? The end goal is to create a new API that effectively forms a command line style variant of what already exists.

I appreciate this question might come across a little confused, as I'm still dipping my toe in and trying to feel my way around the approach.

Upvotes: 0

Views: 47

Answers (2)

Janis F
Janis F

Reputation: 2630

If you are going to write a Command Line Interface for a GUI Application (not the usual approach), then how about instantiating and just not calling .Show() on it? You can control the individual elements from the .Controls -Property of the Form.

Upvotes: 1

Ehsan
Ehsan

Reputation: 32681

Being very new to C#, is it possible to initialise GUI elements and event handlers so that they are valid objects without actually displaying them on the screen?

Yes, you can set their visibility to false. And they won't be visible. Or alternatively you don't add them to any displayed control. If you go to designer.cs file of your form you will see this line.

this.Controls.Add

this is basically adding your control to the form. If you skip this line it won't be displayed.

Upvotes: 1

Related Questions