Menu

#11 Distinctive read-only columns

Unassigned
wont-fix
Feature (10)
5
2018-05-03
2009-10-01
No

Maybe it should be useful to have distinctive read-only columns as an optional OLV behaviour. That's because users have no other indication whether tabular data is editable or not. In my experience, not only read-only columns text color should be grayed out (i.e. color=Gray), but also column background should be grayed-out a bit as well (i.e. color=WhiteSmoke).

Few tips if this suggestion ever gets implemented:

  • Should have user defined BackgroundTint color for read-only columns
  • Should have user defined Foreground (text) color for read-only columns
  • Should play well with AlternateRowBackColor and sorted (possibly tinted) columns

Read-only column "behaviour" may be explicit or implicit:

  • When explicit, then it's set via TypedColumn.IsEditable property.
  • When implicit, inherits its read-only state from the RowObject's AspectGetter, for example:

Public ReadOnly Property Name() As String

is read only, but

Public Property Name() As String

is not.

Implicit read-only behaviour may be grabbed from ReadOnlyAttribute:

// Gets the attributes for the property.
AttributeCollection attributes =
TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;

// Checks to see whether the value of the ReadOnlyAttribute is Yes.
if(attributes[typeof(ReadOnlyAttribute)].Equals(ReadOnlyAttribute.Yes)) {
// Insert code here.
}

// This is another way to see whether the property is read-only.
ReadOnlyAttribute myAttribute =
(ReadOnlyAttribute)attributes[typeof(ReadOnlyAttribute)];
if(myAttribute.IsReadOnly) {
// Insert code here.
}

Discussion

  • Phillip Piper

    Phillip Piper - 2018-05-03
    • status: open --> wont-fix
    • assigned_to: Phillip Piper
    • Group: --> Unassigned
     
  • Phillip Piper

    Phillip Piper - 2018-05-03

    You can do this simply with existing functionality:

    foreach (var column in this.ListView.AllColumns) {
          if (!column.IsEditable)
              this.ListView.AddDecoration(new TintedColumnDecoration(column));
    }
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.