Drawing a line to the window (Winform)
hey, i tried running this code i got from a website trying to draw a line to the screen but it isnt drawing, this is ofc a winforms project, what do i need to do for the line to be drawn? i didnt see the website ever mentioning calling this function anywhere so i thought that it would run without needing to call it or something
28 Replies
Check bottom
That's how you make a paint event
just double-click it and it will automatically create the declaration for you
im on vs code, not visual studio
VSCode barely supports WinForms
Please use VS over VSCode
i think ill switch up later but for now is there any way to do it without needing to use visual studio?
Usually people started by drawing big rectangles to learn about the coordinates first.
so is there any tutorial for that?
i checked it out, i tried doing this but it didnt work, although the example draws a picturebox and not a line
You are not subscribed to the event
Check form load event
foo.MyEvent += Hello;
will subscribe to the event and when the event is called it will call 'Hello' method
That's why VSCode sucks for WinForms.
The controls and event subscriptions are generated underneath when you use the designer in VS, don't know for VSCode but I assume it's as horrible as can be.i see
ill download visual studio* then
how do i open that properties tab?
Check 'View' menu item at the top
and you can open the event tab by clicking the lightning icon
tried doing that and it just opened an empty properties window
You must open the project file *.csproj or the sln file
C# is project-based
You cannot open the project by folder in VS
tried opening the properties tab on the csproj file and it also was empty
Close VS entirely and open the csproj file THROUGH VS
Do not open by local folder - As C# is project based which requires a csproj or sln file
i opened the csproj file through "Open a project or solution" and this showed up
Did you install any workloads?
Open up the app Visual Studio Installer and press modify
then install the workload to the right
'.NET desktop development'
alright i did that
just waiting for it to finish now
alright i opened it now with the .net desktop development thing but it didnt change much
double-click form1
i finally saw the lighting icon
i did what you told me to do the line has been drawn thanks