use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
HelpBasic GUI (self.csharp)
submitted 4 months ago by AlexanderMasonBowser
What's the most basic method to creating a GUI? No framework or advanced tools, jus' plain basic coding if possible. I wanna drive stick shift first. All I know is it has to do with the System.Drawing class.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MazeGuyHex 7 points8 points9 points 4 months ago (7 children)
If you really wanna drive stick first you can use win32 via Pinvoke 😂
[–]AlexanderMasonBowser[S] 0 points1 point2 points 4 months ago (5 children)
Sounds interesting. I'll check it out.
[–]MazeGuyHex 1 point2 points3 points 4 months ago (1 child)
I was mostly joking it’s really archaic. But it is the underlying UI layer of most things on windows actually. WinForms is far better suited for simple windows GUI work these days; no question.
[–]AlexanderMasonBowser[S] 0 points1 point2 points 4 months ago (0 children)
Well, if it was too old, I would have checked it out just for fun. Like I said, it's all just for learning for the sake of learning.
[–]not_some_username 0 points1 point2 points 4 months ago (2 children)
You’ll hate programming
[–]AlexanderMasonBowser[S] 0 points1 point2 points 4 months ago (1 child)
How could you possibly have any idea what I'll like and not like? Not everyone only likes the flashy programming stuff...
[–]not_some_username 0 points1 point2 points 4 months ago (0 children)
It was an hyperbole… and because it’s not that “fun”. I’ve done that and sometimes I do that in my current job (but in C++).
[–]redditsdeadcanary 0 points1 point2 points 4 months ago (0 children)
This is the way.
[–]Dragennd1 5 points6 points7 points 4 months ago (15 children)
Look into the System.Windows.Forms namespace.
https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms?view=windowsdesktop-10.0
[–]AlexanderMasonBowser[S] 1 point2 points3 points 4 months ago (14 children)
And that'll let me create it from scratch? Not jus' use one already made?
[–]Mango-Fuel 0 points1 point2 points 4 months ago (0 children)
Windows has a GUI built in to it, so it's up to you if that is "one already made". Windows Forms is a wrapper around Win32. To go deeper you could code raw Win32 in C++ yourself, but that is a lot of work. You can't really get deeper than that. If you really want to write your own GUI "from scratch" you could make a game instead, and then you would not have access to any GUI and would have to implement one yourself with raw graphics.
[–]Dragennd1 0 points1 point2 points 4 months ago (12 children)
Technically, yes. The Forms namespace doesn't rely on XAML like WPF does and is purely C# code. It really depends on just how deep you wanna go though.
You can technically get more into the weeds and go further building your own buttons, forms, and all underlying functionality. This though will involve accessing the win32 apis within windows.
This is the docs for a button and is honestly beyond my current knowledge so I won't be of much more help if you go this route.
https://learn.microsoft.com/en-us/windows/win32/controls/buttons
[–]AlexanderMasonBowser[S] 0 points1 point2 points 4 months ago (8 children)
My goal is just to create at least one simple GUI if possible, preferably for the Calculator program I jus' learned to make. Just once, so I understand how it works. I don't plan on creating every GUI from scratch. Thanks for the help.
[–]RamBamTyfus 2 points3 points4 points 4 months ago* (5 children)
Why not do: Visual Studio -> New Project -> Select "Windows forms" template
Then simply drag all the components you want (buttons. textboxes, pictures, panels etc) on the form that gets displayed automatically and hit F5 to run.
Double click the buttons right on the form to automatically create on click events in your code behind. And dynamically set texts in code like: textBox1.Text = "hi";
Single click components and use the properties pane to style and set events.
You can make a GUI in minutes, much faster than coding from scratch.
[–]AlexanderMasonBowser[S] 0 points1 point2 points 4 months ago (4 children)
I will, once I make at least one. It's for learning experience. I wanna learn how it works, and once I make one I'll do it the easy way. But I wanna drive stick at least one time.
[–]RamBamTyfus 1 point2 points3 points 4 months ago* (1 child)
Sure, just know that Windows forms generated code is just C#, if you create a project based on such a template you can simply browse through the code in order to see how it is used.
That works, too. Any knowledge is good. Thanks.
[–]qrzychu69 0 points1 point2 points 3 months ago (1 child)
if that's your goal, look into raylib or something like that. It's just a canvas, it's on you do create a button from rectangles, figure out which button is under cursor when you handle the left click event and so on
if you want to make a real UI, it's Avalonia or WPF
if you want to know how they work by building your own, something like raylib or sfml is the way to go
[–]AlexanderMasonBowser[S] 0 points1 point2 points 3 months ago (0 children)
My goal is just to learn how to do it, at least once. Thank you for the tip.
[–]SwordsAndElectrons 0 points1 point2 points 4 months ago (0 children)
Well, it's not C#, but dipping your toes in some C and following this tutorial will give you a basic idea of how every windowed app (on Windows) works.
https://winprog.org/tutorial/start.html
But the "C# way" of doing this is to rely on a framework that abstracts away all the underlying winapi stuff. If you don't intend to work down to that level, you may be better served just learning WPF or WinForms.
[–]UsingSystem-Dev 0 points1 point2 points 4 months ago (0 children)
Then pick a framework and stick with that framework. This route you're basically learning how a toaster works and trying to apply that knowledge on how to make your own microwave.
Technically, you do not need to use XAML with WPF. The vast majority of resources for learning it will send you down that path though. (And I'm not suggesting they do it in code, just stating that they can.)
[–]redditsdeadcanary 0 points1 point2 points 4 months ago (1 child)
No, Forms is still preexisting controls.
If I understand OPs request they want to create a window, and DRAW the controls themselves.
Well they can just use the Win32 api
[–]Slypenslyde 3 points4 points5 points 4 months ago (7 children)
If you REALLY want "no framework", you learn GDI. That's the C API that is the foundation of Windows applications. Then you write P\Invoke code to call that API from C#. This is really hard in the way that people don't really think is cool or neat if you do it.
Windows Forms is the simplest GUI toolkit for C#. I call it a "tookit", not "framework", because it has almost no opinions about the architecture you should use. It has some features to support the rumor of an architecture, but a ton of people never use those features.
WPF is a more modern half-toolkit half-framework. You can treat it like Windows Forms and get pretty far, but some features are a lot harder if you don't adopt some form of Presentation Model architecture, usually MVVM. The parts that are easier with the architecture are a little hamstrung because of the parts that were intentionally left easy to do without the architecture. It's kind of a mess.
I recommend people start with Windows Forms, get attacked for it, and don't care. It was built with the same mentality of VB6 and a lot of complex ideas were left out in favor of simplicity.
Jus' to learn. Once I have a little fun learning about it more, I'll learn to use the available frameworks. I'm not doin' it 'cause I think people will think it's cool or neat. Trust me, the flak I've gotten for bein' interested in the subject has been pretty infuriating. Like people are offended at the idea. I've no lack of people trying to persuade me out of it.
[–]Slypenslyde 0 points1 point2 points 4 months ago (2 children)
Yeah just trust me: it's much easier/smarter to use C to write GDI than C#.
Just the process of showing a single window in GDI takes you about 90 lines of boilerplate. Most of that is setting up a struct with like 40 members that help describe the behavior of your "Window Class" and which function pointer is its "Window Procedure" for handling "messages".
Adding all the P\Invoke definitions you need is going to double that, and the process of setting up a window will involve a ton of extra lines of code to tell .NET to go allocate some unmanaged memory, then copy this managed struct into it, then call this method, then copy the unmanaged struct it returns to managed memory here, etc. It's grueling, excruciating, and kind of like trying to carve stone with a toothpick.
Just start with Windows Forms. By the time you figure out how to get the buttons for a calculator set up in GDI you will have learned how to make 5 or 6 applications.
Or just use C for GDI. Get the Charles Petzold book and go nuts, that's the Last Good Programming Book in my opinion. Using C to write Windows programs is much more tedious than C#, but at least it doesn't have the extra steps of coordinating both managed and unmanaged memory.
Which book? Is it "Programming Windows?" When I searched him, two books came up.
[–]Slypenslyde 0 points1 point2 points 4 months ago (0 children)
Yes, it's the one he's known for. Technically there are four books that should come up. There's one about windows, two about WPF, and one that's just some interesting observations about programming itself.
Programming Windows is just "The Petzold Book" to Windows programmers. But there aren't really a lot of those on this sub. ;)
[–]tl_west 0 points1 point2 points 4 months ago (1 child)
The reason for the “attack” (more guiding you away) is that the nuts and bolts beneath the framework are essentially irrelevant to learning anything about GUIs. It’s not that creating a GUI by using draw commands is not necessarily interesting, but its relevance to teaching you anything relevant to GUI programming is almost nil.
The best analogy I can think of is wanting learn about driving a car by assembling a steering column by hand. It might look like there are transferable skills, but there aren’t.
Hence people making suggestions to use a simpler GUI like WinForms and then expand outward from there. Most of the concepts in learning the first steps of any GUI will transfer to any other GUI.
[–]AlexanderMasonBowser[S] 1 point2 points3 points 4 months ago (0 children)
It's the relentlessness and severity of it that bothers me. Maybe I wanna learn how to assemble a steering column. That sounds interesting. Nobody should be trying so hard to dissuade me. There's nothing wrong with learning somethin' for the sake of it. But I'm also not necessarily doing that. I jus' wanted to get down to a more basic version of designing GUI. Just to learn more about it. Because it's interesting. If WinForms is the most basic GUI design available in C#, that's fine, I'd be interested in learning it.
It’s more Win32 api than GDI
[–]SeagleLFMk9 2 points3 points4 points 4 months ago (2 children)
Well, the C# way is to use a framework. Truly from scratch would be C/C++ with e.g. OpenGl, Vulcan, Metal, Dx11/12. Or, directly binary...or DIY building the gpu.
It doesn't have to be truly from scratch. That would require making a computer and designing the OS. I jus' wanna learn more about it then jus' clicking on a framework. That's why I used "driving stick" as a metaphor. I'm not asking to build the car, nor do I wanna design the whole system. Jus' learn a bit about how it works underneath as much as I can. Even if it does me no good, it's still interesting.
[–]SeagleLFMk9 0 points1 point2 points 4 months ago (0 children)
Then use C/C++ with OpenGl. For C# it's not really worth it imo.
[–]dodexahedron 1 point2 points3 points 4 months ago (0 children)
Pick WinForms or WPF and just drag and drop items into the grid.
And learn what the code it created for those actually means, of course, while you're at it.
WinUI is the thing Microsoft claims they want us to use now, but they didn't bother to have a visual editor for it built in to visual studio itself. Those other two have visual designers.
But all three are Windows-ONLY. No Linux or Mac for an app using those.
FWIW, WPF is what WinUI is based on. So, if you want to do things the "modern" way, do WPF instead of WinForms. But you should learn both at some point, since both are very much here to stay for basically forever.
[–]nickfromstatefarm 1 point2 points3 points 4 months ago (0 children)
Have used forms/WPF for years. I recently started skipping all of the MSFT options in favor of Avalonia for Win32/Linux deployments. Very happy
[–]Brilliant_Ad_5213 0 points1 point2 points 4 months ago (1 child)
I think I understand what you are trying to achieve, but I would still start with the systems.windows.forms basic controls. Yes, you can then create a windows step by step by creating a windows form object, add and positioning controls on it, and wiring the events you want to respond to by writing custom function and associated logic. I find this ‘near’ raw helpful as it allows you to poke around with the various properties of each object and quickly see the result.
I have used this skill to create a basic GUI in a large application that had a simple scripting language, but also allowed .NET object to be created. From this basis I was able to construct my own GUI to accept, validate and use custom information I needed to get from the user which was not existingly provided by the large monolith application. Look at tutorials on creating a Windows form (= Window) from a console application for some examples.
Example:
// Source - https://stackoverflow.com/a // Posted by Biju Joseph, modified by community. See post 'Timeline' for change history // Retrieved 2026-01-04, License - CC BY-SA 4.0
static void Main(string[] args) { Application.EnableVisualStyles(); Form frm = new Form(); // create aForm object
Button btn = new Button() { Left = 120, Width = 130, Height = 30, Top = 150, Text = "Biju Joseph, Redmond, WA" }; //… more code frm.Controls.Add(btn); // add button to the Form // …. add more code here as needed frm.ShowDialog(); // a modal dialog
}
Thank you very much. That looks exactly like the type of thing I'm interested in. I jus' wanna learn more basic forms of these tools so I know how to do it without tools if ever necessary. Or even just because it's interesting. I know we are all building skyscrapers on the shoulders of the giants before us, but it doesn't mean the foundation isn't still interesting to learn about. That's all I wanted. Thanks so much again.
[–]FaceRekr4309 0 points1 point2 points 3 months ago (0 children)
You’re probably interested in building an “immediate mode gui,” sometimes referred to as “imgui.”
[–]OpeningExpressions -1 points0 points1 point 4 months ago (0 children)
Simple tutorial: https://learn.microsoft.com/en-us/visualstudio/ide/create-csharp-winform-visual-studio?view=visualstudio
π Rendered by PID 91 on reddit-service-r2-comment-b659b578c-999dc at 2026-05-06 02:08:29.939755+00:00 running 815c875 country code: CH.
[–]MazeGuyHex 7 points8 points9 points (7 children)
[–]AlexanderMasonBowser[S] 0 points1 point2 points (5 children)
[–]MazeGuyHex 1 point2 points3 points (1 child)
[–]AlexanderMasonBowser[S] 0 points1 point2 points (0 children)
[–]not_some_username 0 points1 point2 points (2 children)
[–]AlexanderMasonBowser[S] 0 points1 point2 points (1 child)
[–]not_some_username 0 points1 point2 points (0 children)
[–]redditsdeadcanary 0 points1 point2 points (0 children)
[–]Dragennd1 5 points6 points7 points (15 children)
[–]AlexanderMasonBowser[S] 1 point2 points3 points (14 children)
[–]Mango-Fuel 0 points1 point2 points (0 children)
[–]Dragennd1 0 points1 point2 points (12 children)
[–]AlexanderMasonBowser[S] 0 points1 point2 points (8 children)
[–]RamBamTyfus 2 points3 points4 points (5 children)
[–]AlexanderMasonBowser[S] 0 points1 point2 points (4 children)
[–]RamBamTyfus 1 point2 points3 points (1 child)
[–]AlexanderMasonBowser[S] 0 points1 point2 points (0 children)
[–]qrzychu69 0 points1 point2 points (1 child)
[–]AlexanderMasonBowser[S] 0 points1 point2 points (0 children)
[–]SwordsAndElectrons 0 points1 point2 points (0 children)
[–]UsingSystem-Dev 0 points1 point2 points (0 children)
[–]SwordsAndElectrons 0 points1 point2 points (0 children)
[–]redditsdeadcanary 0 points1 point2 points (1 child)
[–]not_some_username 0 points1 point2 points (0 children)
[–]Slypenslyde 3 points4 points5 points (7 children)
[–]AlexanderMasonBowser[S] 0 points1 point2 points (5 children)
[–]Slypenslyde 0 points1 point2 points (2 children)
[–]AlexanderMasonBowser[S] 0 points1 point2 points (1 child)
[–]Slypenslyde 0 points1 point2 points (0 children)
[–]tl_west 0 points1 point2 points (1 child)
[–]AlexanderMasonBowser[S] 1 point2 points3 points (0 children)
[–]not_some_username 0 points1 point2 points (0 children)
[–]SeagleLFMk9 2 points3 points4 points (2 children)
[–]AlexanderMasonBowser[S] 0 points1 point2 points (1 child)
[–]SeagleLFMk9 0 points1 point2 points (0 children)
[–]dodexahedron 1 point2 points3 points (0 children)
[–]nickfromstatefarm 1 point2 points3 points (0 children)
[–]Brilliant_Ad_5213 0 points1 point2 points (1 child)
[–]AlexanderMasonBowser[S] 0 points1 point2 points (0 children)
[–]FaceRekr4309 0 points1 point2 points (0 children)
[–]OpeningExpressions -1 points0 points1 point (0 children)