Answer the question
In order to leave comments, you need to log in
How to draw an element in a picturebox in Winform?
Hello.
There is such a hitch. I can't draw an element in a picturebox if I'm not doing it from the main Winfom window.
Let me explain:
There is a main form and when you click on the button, a square is drawn in an empty white field. The code is attached to the button
(carefully pseudocode)
Object.AddFigure<Фигура>(тут указываются Point для позиции);
Update() ResetText() Application.Restart()
Answer the question
In order to leave comments, you need to log in
As a Variant solution through events proposed by edward_freedom
The solution that was suggested to me is simpler.
When creating a form, on button click, toggles this . This is the main implicit form Form1 itself, which we can finally use later.
Next, in the most child form with buttons, we make a field and assign a value to it. And TADAAM we can call the field and access the methods of Form1 .
var createform = new LoadProject(this);
Form1 _main; // Поле
public LoadProject(Form1 main)
{
InitializeComponent();
_main = main;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question