C
C#15mo ago
MadeInHevinis

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

Did you find this page helpful?