Note that there are some explanatory texts on larger screens.

plurals
  1. PO.NET Designer issues shadowing properties as readonly in inherited controls
    primarykey
    data
    text
    <p>I am trying to create custom controls to provide some consistency to the design of an application. However when I shadow a property with a readonly alternatvie, I get designer errors at build time. Now I can delete the offending lines of code in the designer file and continue to build and run my application but firstly this is irritating, and secondly it tells me that I must be doing something fundamentally wrong!</p> <p>Here's an example of a control that overrides datagridview</p> <pre><code>Class standardDataGridView Inherits DataGridView Public Sub New() MyBase.New() Me.RowHeadersVisible = False MyBase.SelectionMode = DataGridViewSelectionMode.FullRowSelect MyBase.MultiSelect = False Me.ReadOnly = True Me.BackgroundColor = Color.White Me.AllowUserToDeleteRows = False Me.AllowUserToResizeRows = False Me.AllowUserToAddRows = False End Sub Public Shadows ReadOnly Property SelectionMode As DataGridViewSelectionMode Get Return MyBase.SelectionMode End Get End Property Public Shadows ReadOnly Property MultiSelect As Boolean Get Return MyBase.MultiSelect End Get End Property End Class </code></pre> <p>In the first build after adding one of these controls to a form, or after changing any properties, the following lines get added to the designer file by Visual Studio:</p> <pre><code>Me.standardDataGridView1.MultiSelect = False Me.standardDataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect </code></pre> <p>Which results in the following build errors</p> <pre><code>Property 'MultiSelect' is 'ReadOnly'. Property 'SelectionMode' is 'ReadOnly' </code></pre> <p>As I say... I can remove the lines that Visual Stuido added, and continue, but where have I gone wrong to be getting this problem?</p>
    singulars
    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