Drop shadow in Winforms Controls?

You have to overwrite the CreateParamsproperty like this: private const int CS_DROPSHADOW = 0x00020000; protected override CreateParams CreateParams { get { // add the drop shadow flag for automatically drawing // a drop shadow around the form CreateParams cp = base.CreateParams; cp.ClassStyle |= CS_DROPSHADOW; return cp; } }

Setting Button FlatStyle in WPF

The ToolBar class defines a Style that makes Buttons look flat. An example of using it is: <Button Style=”{StaticResource {x:Static ToolBar.ButtonStyleKey}}”/> This also works for a ToggleButton when using ToggleButtonStyleKey. WPF lets you completely restyle controls to make them look like whatever you want, which is why it doesn’t have such a specific FlatStyle property … Read more

Why controls do not want to get removed?

You have to watch out for code like this, removing controls from their container like this produces an unrecoverable resource leak. Controls.Remove/At(), or the Controls.Clear() method as suggested by other posters, removes the control from the collection and re-hosts it to the “parking window”. An otherwise invisible window where the native window can find a … Read more

Resize Controls with Form Resize

The best option is to use a TableLayoutPanel. Put TableLayoutPanel on the form, set the Dock property to Fill, create required rows and columns and put the controls inside the cells. Of course you need to set Dock/Anchor on the controls inside the cells, so they respond to changes to the cell size. In some … Read more

Catch Textbox Scroll Event?

Assuming WinForms, you can try pinvoking: public class MyRTF: RichTextBox { private const int WM_HSCROLL = 0x114; private const int WM_VSCROLL = 0x115; private const int WM_MOUSEWHEEL = 0x20A; protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == WM_VSCROLL || m.Msg == WM_HSCROLL || m.Msg == WM_MOUSEWHEEL) { // scrolling… } } … Read more

Avoid calling Invoke when the control is disposed

What you have here is a race condition. You’re better off just catching the ObjectDisposed exception and be done with it. In fact, I think in this case it is the only working solution. try { if (mImageListView.InvokeRequired) mImageListView.Invoke(new YourDelegate(thisMethod)); else mImageListView.RefreshInternal(); } catch (ObjectDisposedException ex) { // Do something clever }