❔ Creating a new project in Windows forms app and adding controls

88 Replies
Thinker
Thinker2y ago
$newproject
MODiX
MODiX2y ago
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework. .NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended. https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
Thinker
Thinker2y ago
Please do not select anything that says ".NET Framework"
The king of kings
1. Create a program where the user can add and remove elements from a listBox object. 2. Make a program with a PictureBox that changes the picture according to which of three RadioButtons the user has selected. 3. Create a Windows Forms project that contains a webBrowser object. Use the .Navigate method to navigate to a url. Ok How come? Is it outdated or something?
Pobiega
Pobiega2y ago
come on man You've been here for almost a year now
The king of kings
Let me delete the project then and create a new one but this time without a .NET Framework
Pobiega
Pobiega2y ago
surely you must have picked up on the fact that .net framework is indeed very old and outdated at this point
The king of kings
Ok! Now, I'm aware of that and surely, I won't think about using it at all.
The king of kings
Which one should I use then?
Pobiega
Pobiega2y ago
Pobiega
Pobiega2y ago
this one since your post title clearly says "windows forms", not "WPF"
The king of kings
Ok! Awesome. Thanks a lot. May, I know why you prefer WPF?
Pobiega
Pobiega2y ago
winforms is very very old
The king of kings
Ok
Pobiega
Pobiega2y ago
it uses an outdated imperative approach to UIs, while WPF is more declarative
The king of kings
Aha! Ok!
Pobiega
Pobiega2y ago
doesnt matter thou, your course says to use winforms so use winforms
The king of kings
But none of the options in my screenshots corresponds to this one? . Yeah! I'll just follow the course requirements for now. All of them are Framework
Pobiega
Pobiega2y ago
I dunno, seems you only get framework suggestions. Did you check the "Desktop development" workload when you installed Visual Studio?
The king of kings
I don't remember to be honest with you What would be the alternative do you think?
Pobiega
Pobiega2y ago
there are no alternatives you cant substitute the correct project type for another lol so close down visual studio, start the VS installer and check what workloads you have
Pobiega
Pobiega2y ago
The king of kings
Should I click here and maybe reinstall Winforms?
The king of kings
Ok
Pobiega
Pobiega2y ago
Pobiega
Pobiega2y ago
you need this one.
The king of kings
Ok Awesome. It's installed now. Yahhhee
Pobiega
Pobiega2y ago
there you go
The king of kings
Should I use .NET 6.0 or 7.0? Yep
Thinker
Thinker2y ago
7.0
The king of kings
Great
The king of kings
This time, I'm not able to reach to the toolbox.
Pobiega
Pobiega2y ago
have you tried opening the toolbox? its under View
The king of kings
I found it, thanks a lot. Now. it's time apply these.
Pobiega
Pobiega2y ago
yes.
The king of kings
How do I edit the label to "Add"?
Pobiega
Pobiega2y ago
click the label then edit the property, as you tried doing but you need to have the label selected, not the form itself
Pobiega
Pobiega2y ago
you can also select it here
The king of kings
Ok
The king of kings
I wonder what the label its roll is?
The king of kings
Haritha Computers & Technology
YouTube
How To Add Remove Items In Listbox Dynamically Winforms c#4.6
#listbox #addremovelistbos #dynamicallylistboxitems add and remove items from the listbox control from textbox dynamically in windows application winforms
Pobiega
Pobiega2y ago
Label is just for showing text thats it
The king of kings
Ok! But I could've edit my buttons text to Add and Remove why would I need a label too?
Pobiega
Pobiega2y ago
because not everything is a button?
The king of kings
No I have a listBox and textBox
Pobiega
Pobiega2y ago
for example, if you have 3 textboxes next to eachother
The king of kings
Yes
Pobiega
Pobiega2y ago
it might be useful to label them, so the user knows what goes in what box
The king of kings
Ok Now I see why we need to use it
The king of kings
How do I get rid of this and go back to my UI window?
The king of kings
This appeared after making a change in the code
Pobiega
Pobiega2y ago
you added an event binding then removed the code for the event handler you'll need to edit the designer file
trunksvn
trunksvn2y ago
As the guy above me said, you added a control Event handler then u removed and now u need to go on Solution Explorer, open the arrow (dropdown) of your Form an then go on Form1.Designer.cs, after that u will need to find a metho named InitializeComponent(), Go inside of it and find the code line that has a Red Curl and erase that line.
The king of kings
Ok! Thanks a lot for showing up and identifying where the issue is located. The problem is already solved. Now, I need to figure out this step
Create a Windows Forms project that contains a webBrowser object. Use the .Navigate method to navigate to a url.
Create a Windows Forms project that contains a webBrowser object. Use the .Navigate method to navigate to a url.
trunksvn
trunksvn2y ago
Aight, any issue feel free to ask
The king of kings
Thanks a lot bro
trunksvn
trunksvn2y ago
<:cc_cat8:1046829995147923587>
The king of kings
Am I in the right section?
trunksvn
trunksvn2y ago
I think so
trunksvn
trunksvn2y ago
What u wanna do?
The king of kings
Let me show you what I'm working on
trunksvn
trunksvn2y ago
Change the name of the object?
The king of kings
I'm following this tutorial in order to be able to build my project https://learn.microsoft.com/en-us/microsoft-edge/webview2/get-started/winforms
Get started with WebView2 in WinForms apps - Microsoft Edge Develop...
Getting started guide for using WebView2 for WinForms apps.
The king of kings
No 3. Create a Windows Forms project that contains a webBrowser object. Use the .Navigate method to navigate to a url.
The king of kings
So I got little stuck here
Pobiega
Pobiega2y ago
WebView2 is a much newer control.
trunksvn
trunksvn2y ago
Hmm I never worked with that control but, what u not comprehending from it? I think it's very clean what they are saying
The king of kings
Great to see again my man Yeah this is what I noticed too
trunksvn
trunksvn2y ago
On source property u need to add the URI aka the url of the site
The king of kings
Yes
trunksvn
trunksvn2y ago
Once u add that it will be displayed on webview2
The king of kings
I just wanted to dabble check if it's the correct section Ok
trunksvn
trunksvn2y ago
Then they say to save the project and run pressing F5
trunksvn
trunksvn2y ago
Yh it seems right
The king of kings
Ok! Let me do this too. Yep
trunksvn
trunksvn2y ago
Also everytime u add a control normally u edit first the name of the control to his context: WbvDisplayMicrosoft Not the best example but.. hope u understand I'll give a better example
The king of kings
Here we go
The king of kings
Ok! Yeah! You're right. Some developers told me the same yesterday here in the server.
trunksvn
trunksvn2y ago
Once u add the label control: The property name will be by default: Label1 And if u add that label to indicate a specific section let's imagine List of Users. The name of the Label1 should be LblListUsers . So Labels u change to Lbl.., Textboxs to Txt.., etc.. Seems good Best practice, so you can know what each control means and if u share the project to a friend he will know what each control work My English not the best but I try my best to make u understand me
The king of kings
Yes You are very correct brother. It's much easier to understand a project & code if you use correct clear names. No, your English is perfect. Mine is not that good 😄 Where you from btw?
trunksvn
trunksvn2y ago
Sorry just arrived Home, im from Portugal grinowo fine dont worry
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server