How do I format a date column in a datagrid
If you have added a table style to your datagrid (so individual column styles have been generated), then you can use code such as this to set the Format property of the particular column style. [C#] //add format col 3 columnstyle where column 3 holds a date… DataGridTextBoxColumn dgtbc; dgtbc = dataGrid1.TableStyles[0].GridColumnStyles[3] as DataGridTextBoxColumn; if(dgtbc != null) dgtbc.Format = ‘g’; // or ‘u’ or whatever format you want to see [VB.NET] ’add format col 3 columnstyle where column 3 holds a date… Dim dgtbc as DataGridTextBoxColumn dgtbc = CType(dataGrid1.TableStyles(0).GridColumnStyles(3), DataGridTextBoxColumn) If Not dgtbc is Nothing Then dgtbc.Format = ‘g’ ’ or ‘u’ or whatever format you want to see End If
How can I listen to changes in a file/directory in the windows file system?
Use FileSystemWatcher to watch for changes in a specified directory. You can watch for changes in files and subdirectories of the specified directory. The component can watch files on a local computer, a network drive, or a remote computer.
How do I automatically resize the Form when the screen resolution changes between design-time and runtime?
The framework automatically resizes the form if the current Font size during runtime is different from the font size in design-time. It however doesn’t auto size when the resolution changes. But it should be easy for you to accomplish. You could derive a custom Form, provide a ‘ScreenResolutionBase’ property that could return the current screen resolution (Screen.PrimarScreen.Bounds will give you this). This value will get serialized in code during design time. Then during runtime in the Form’s OnLoad you could check for the current screen resolution and resize the Form appropriately.
How do I determine the screen resolution?
Use the System.Windows.Forms.Screen.PrimaryScreen.Bounds property.
How do I determine the width/height of the Non-Client area (like the border in a textbox) of a Control?
One generic way for all Controls is to get the difference between the ClientRectangle’s width and the Control.Bounds’ width. That should give the border width (and in general the NC area width); similarly for height.