C
C#5mo ago
Hevinis

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
No description
28 Replies
Buddy
Buddy5mo ago
Check bottom
No description
Buddy
Buddy5mo ago
That's how you make a paint event just double-click it and it will automatically create the declaration for you
Hevinis
Hevinis5mo ago
im on vs code, not visual studio
Buddy
Buddy5mo ago
VSCode barely supports WinForms Please use VS over VSCode
Hevinis
Hevinis5mo ago
i think ill switch up later but for now is there any way to do it without needing to use visual studio?
Lex Li
Lex Li5mo ago
Usually people started by drawing big rectangles to learn about the coordinates first.
Hevinis
Hevinis5mo ago
so is there any tutorial for that?
Hevinis
Hevinis5mo ago
i checked it out, i tried doing this but it didnt work, although the example draws a picturebox and not a line
No description
Buddy
Buddy5mo ago
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.
Hevinis
Hevinis5mo ago
i see ill download visual studio* then how do i open that properties tab?
Buddy
Buddy5mo ago
Check 'View' menu item at the top and you can open the event tab by clicking the lightning icon
Buddy
Buddy5mo ago
No description
Hevinis
Hevinis5mo ago
tried doing that and it just opened an empty properties window
No description
No description
Buddy
Buddy5mo ago
You must open the project file *.csproj or the sln file C# is project-based You cannot open the project by folder in VS
Hevinis
Hevinis5mo ago
tried opening the properties tab on the csproj file and it also was empty
No description
Buddy
Buddy5mo ago
Close VS entirely and open the csproj file THROUGH VS
Buddy
Buddy5mo ago
No description
Buddy
Buddy5mo ago
Do not open by local folder - As C# is project based which requires a csproj or sln file
Hevinis
Hevinis5mo ago
i opened the csproj file through "Open a project or solution" and this showed up
No description
Buddy
Buddy5mo ago
Did you install any workloads? Open up the app Visual Studio Installer and press modify
Buddy
Buddy5mo ago
then install the workload to the right
No description
Buddy
Buddy5mo ago
'.NET desktop development'
Hevinis
Hevinis5mo ago
alright i did that just waiting for it to finish now
Hevinis
Hevinis5mo ago
alright i opened it now with the .net desktop development thing but it didnt change much
No description
Buddy
Buddy5mo ago
double-click form1
Hevinis
Hevinis5mo ago
i finally saw the lighting icon i did what you told me to do the line has been drawn thanks
Buddy
Buddy5mo ago
Clap