• 0

Drawing problem with list box [.NET]


Question

Ok, this might be hard to understand but anyways:

i'm currently inheriting from the ListBox control and providing my own drawing code.

I'm drawing a gradient background on each listbox item. All fine, however the gradient i'm drawing is a little away from the edge of the actual rectangle so youll see some white space around the actual rectangle.

All fine till when you run it and when u resize the listbox, only the first item gets refreshed and draw appropriately.

If i drew the gradient so that it covered the whole rectangle up with no spaces between the edges, and if i resize it during runtime, all the items become drawn correctly.

Here's a screenshot of the issue when it's resized

http://www.ug.it.usyd.edu.au/~wpan6331/ss/ss.JPG

Has anyone experienced the same situation before?

Thanks

Link to comment
https://www.neowin.net/forum/topic/270286-drawing-problem-with-list-box-net/
Share on other sites

13 answers to this question

Recommended Posts

  • 0
  dannyres said:
You could try setting the ControlStyles.ResizeRedraw flag.. I'm pretty sure that will fix your problem..

this.SetStyle(ControlStyles.ResizeRedraw, true);

By the way very nice looking listbox you've got there. :)

Dan

585278752[/snapback]

Thanks, i've tried al the SetStyle options.

Doesn't help, try it yourself actually, if u dont mind

draw a gradient inside a listbox item, and make it so that its off the edges of the rectangle and resize and ullsee it happen too.

  • 0
  dannyres said:
Ah ok, I don't have time to try it myself right now, but you could try filling the bounds with white (Graphics.Chear(Color.White);) then drawing ontop of that.. Hopfully that will solve your problem.. :)

Dan

585281362[/snapback]

lol that doesn't really work, it then causes only one listbox item to be drawn.

  • 0

Ok update guys, i overrided OnResize, so i have to invoke mybase's resize method, added ResizeRedraw for the styles that fixed it up, now i'm left with a listbox that flickers really badly, has anyoen got any other tips they can share to avoid this flickering, i've used double buffer, doesn't work, it also said to truly enable double buffer u have to set the AllWmPaint one and the UserPaint styles, however UserPaint stuffs up the drawing.

Any other suggestions guys?

Thanks

  • 0
  dannyres said:
You could try doing the double buffering yourself by creating a temporary Bitmap object which you will draw ontop, then paint that to the screen.. :)

Dan

585284364[/snapback]

I did that in some test code and it didn't help for me, although the SetStyle with DoubleBuffer worked for me.

What kind of paint trouble do you get when you use SetStyle?

  • 0
  weenur said:
I did that in some test code and it didn't help for me, although the SetStyle with DoubleBuffer worked for me.

What kind of paint trouble do you get when you use SetStyle?

585284643[/snapback]

Hmmm i'm gonna have to show you, sometime when you're free and when you're on msn lol

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • It's weird how some people don't know how to read the article... "If you remember the tests SpaceX was performing around 2012 with Grasshopper, well Honda is at about the same stage with its reusable rocket."
    • Microsoft Project 2021 Professional for Windows now just $9.97 by Steven Parker Today's highlighted deal comes from our Apps & Software section of the Neowin Deals store, where you can save $240 off Microsoft Project 2021 Professional for Windows. Be the boss of any project with Microsoft Project Professional 2021. This powerful yet easy-to-use app lets you stay on track, from small tasks to larger projects. Manage your projects more efficiently with the right timelines, budgets, and resources. You'll get automated scheduling tools as well as built-in reports to help you reduce inefficiencies and make better, informed decisions. Project management has never been this easy with Microsoft Project Pro. Lifetime license for Microsoft Project Professional 2021 One-time purchase installed on 1 Windows PC for use at home or work Instant Delivery & Download – access your software license keys and download links instantly Free customer service – only the best support! Why Microsoft Project Professional 2021? Pre-built templates help you get your project started on the right track Sync with Project Online and Project Server Submit timesheets to capture time spent on project and non-project work Run what-if scenarios to make the most of your task assignments Auto-populate start and end dates based on dependencies Visually represent complex schedules with built-in multiple timelines Supports Long-Term Servicing Channel (LTSC) and is compatible with Office LTSC and Office 2021 Good to know Length of access: lifetime Redemption deadline: redeem your code within 30 days of purchase Access options: desktop Max number of device(s): 1 Version: 2021 Pro Updates included Microsoft Project 2021 Professional for Windows normally costs $249.99, but it can be yours for just $14.97 for a limited time, that's a saving of $235. For terms, specifications, and license info please click the link below. Use MSO5 when checking out for additional $5 off. Coupon Expires June 29 Get Microsoft Project 2021 Professional for Windows for just $9.97, or learn more Although priced in U.S. dollars, this deal is available for digital purchase worldwide. We post these because we earn commission on each sale so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: Neowin benefits from revenue of each sale made through our branded deals site powered by StackCommerce.
    • Weird how some people don't need to crash 7 rockets before they get it right.
    • Or it's a bug that can easily be fixed with an update. My guess is the limitation is there to prevent game makers from doing dumb things like having a racing game constantly rumble while the car is in motion. Sounds like the threshold or detection needs to be tweaked if it is triggering for no reason.
    • Nice I guess. Azure's DaaS feature has supported that for years. It's so odd to me how MS is deploying Azure and 365 DaaS as two totally different services with different features. I would think the 365 cloud desktops would just be a slightly dumbed down frontend that manages the same service.
  • Recent Achievements

    • Week One Done
      slackerzz earned a badge
      Week One Done
    • Week One Done
      vivetool earned a badge
      Week One Done
    • Reacting Well
      pnajbar earned a badge
      Reacting Well
    • Week One Done
      TBithoney earned a badge
      Week One Done
    • First Post
      xuxlix earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      676
    2. 2
      ATLien_0
      286
    3. 3
      Michael Scrip
      224
    4. 4
      +FloatingFatMan
      197
    5. 5
      Steven P.
      137
  • Tell a friend

    Love Neowin? Tell a friend!