Snippets tagged winforms

  • Structural BeginUpdate / EndUpdate with Lambda

    Several WinForms controls, like TreeView and ListView, implement methods BeginUpdate and EndUpdate, which suspend repainting of the control while items are being individually added to a control, preventing flicker caused by rapid repainting. But using BeginUpdate and EndUpdate is very imperative, and opens up the possibility for bugs, such as neglecting to call the matching EndUpdate. An obvious improvement would be to create an extension method on types implementing this pattern which takes a unit -> unit lambda which is executed between update pairs. But the pattern is only conventional, rather than through a common base class or interface. Hence this presents a reasonable opportunity to use F#'s statically resolved structural type system to implement a function which only works on Control types with the correct structural signature.

    3 people like this

    Posted: 10 years ago by Stephen Swensen

  • Basic WinForms drag and drop

    Quick example of using drag-n-drop with WinForms.

    4 people like this

    Posted: 10 years ago by MichaelGG

  • Auto-completion in any winforms text box

    The standard windows.forms text box supports auto-completion, but only for single-line text boxes. The code below can be used to add auto-completion against a fixed set of words to any text box that inherits from TextBoxBase.

    5 people like this

    Posted: 9 years ago by Johann Deneux

  • Flappy Bird clone using WinForms

    Flappy bird clone script using WinForms, click the mouse or hit space to flap, no collision detection.

    5 people like this

    Posted: 1 year ago by Phillip Trelford