ā Winforms redraw question
To start: I am still a very early beginner in c# and winforms, so sorry if im asking something obvious.
I am trying to make a personal desktop application for displaying games from a database.
At first I had displayed the data in a datagridview but after getting a bit better at c# I was trying to add panels to a panel that had a picture and some text (see picture1 (ignore the text, I was still testing stuff)). Now I finally got the panels to be added programmatically, but now whenever I scroll through the panel that has autoScroll on the dynamically added panels with the game pictures get redrawn or reloaded (see picture2).
Now what I was wondering is why this happens? I assume it has something to do with the fact that there are so many images (the panels themselves all have background images, the tag labels (the yellow and gray pieces) also are images)
Below is the method I made to draw the panels
https://pastebin.com/rZy6QNtP
If any more info is needed to help, please let me know
Pastebin
drawGamePanel - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
10 Replies
Since nobody answered, I'm gonna give it a try.
First things first, WinForms isn't made for such fancy things, it uses GDI+ engine to draw the
Windows
. Which is fine as long as you don't do something extraordinary with animations, pictures and a lot of Controls
.
DoubleBuffer
helps, but isn't the solution to everything.
However, WinForms has it's limits. I would advice you to use WPF or Avalonia (Cross-Platform). Unlike WinForms, WPF doesn't use GDI+, but is built upon DirectX, so it's able to use your graphic card for rendering; GDI/GDI+ uses the CPU only.
That opens a whole new world of fancy UI stuff like you obviously wanna do.
Besides what I wrote; your cards should be a seperate UserControl
with it's respective properties, like image, hours played, achievements, name, etc.still, that artifacts shouldn't happen
I had a feeling I was pushing the limits. Guess its time to learn WPF. Thanks for the info. Guess ill have to start from scratch
Oh yeah that would have been smart
$wpf
WPF is the DirectX and XAML powered, Windows-only desktop GUI framework. You should prefer to use this over Windows Forms where you can.
Hello World in WPF: https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-wpf
Anyone got any recommendations for good tutorials for total beginners? š
for WPF? https://wpf-tutorial.com/
also with WPF u do not ever drag and drop controls like in winforms $rulesofwpf
Thanks a ton, excited to start learning WPF
Thank to everyone who responded :yotsubless:
If you have no further questions, please use /close to mark the forum thread as answered