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