Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere to set custom control defaults
    primarykey
    data
    text
    <p>This one has stumped me now for a little bit. I am creating a derived <code>System.Windows.Forms.DataGridView</code> control with some sensible default values. Now to make this clear they are simply default values and should be capable of being changed in the designer. As of right now I have the default values being set in the controls constructor:</p> <pre><code>using System.Drawing; using System.Windows.Forms; namespace TruckSmart.Controls { /// &lt;summary&gt; /// An implementation of a System.Windows.Forms.DataGridView with sensible default values. /// &lt;/summary&gt; public class DataGrid : System.Windows.Forms.DataGridView { /// &lt;summary&gt; /// Initializes a new instance of the TruckSmart.Controls.DataGrid class. /// &lt;/summary&gt; public DataGrid() { AllowUserToAddRows = false; AllowUserToDeleteRows = false; AllowUserToOrderColumns = false; AllowUserToResizeColumns = false; AllowUserToResizeRows = false; AutoGenerateColumns = false; AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; BackgroundColor = SystemColors.Window; BorderStyle = BorderStyle.Fixed3D; ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; Margin = new Padding(0); MultiSelect = false; ReadOnly = true; RowHeadersVisible = false; SelectionMode = DataGridViewSelectionMode.FullRowSelect; AlternatingRowsDefaultCellStyle = new DataGridViewCellStyle() { BackColor = Color.FromKnownColor(KnownColor.AliceBlue) }; ColumnHeadersDefaultCellStyle = new DataGridViewCellStyle() { WrapMode = DataGridViewTriState.False }; } } } </code></pre> <p>The main problem with using the constructor is that when I close my form designer in Visual Studio and re-open it the constructor is called again and any changes I made previously in the designer are reset. Is there a special place I should be putting these default values?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload