Exposing class properties for design time use
-
If I have a class:
public class Column
{private int \_columnWidth; \[Category("Columns")\] public int ColumnWidth { get { return \_columnWidth; } set { \_columnWidth = value; } } }
How can I expose the property 'ColumnWidth' for design time use please?
-
If I have a class:
public class Column
{private int \_columnWidth; \[Category("Columns")\] public int ColumnWidth { get { return \_columnWidth; } set { \_columnWidth = value; } } }
How can I expose the property 'ColumnWidth' for design time use please?
Hi all, I also have the same issues if anyone can help he/she forward the answer to my e-mail address:omekings2000@yahoo.co.uk cos am currently building a project at hand now.
-
If I have a class:
public class Column
{private int \_columnWidth; \[Category("Columns")\] public int ColumnWidth { get { return \_columnWidth; } set { \_columnWidth = value; } } }
How can I expose the property 'ColumnWidth' for design time use please?
use browsable attribute. [BrowsableAttribute(true)]
-
use browsable attribute. [BrowsableAttribute(true)]
Nice thought. But, however, this did not work for me.
-
Nice thought. But, however, this did not work for me.
Works for me - [System.ComponentModel.Browsable(true)]
It definitely isn't definatley
-
Works for me - [System.ComponentModel.Browsable(true)]
It definitely isn't definatley
That's interesting. Mmm ... so in the code shown below, exactly where are you inserting the [System.ComponentModel.Browsable(true)] please?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace MultiColumnComboBox
{public partial class MultiColumnComboBox : ComboBox { public class Column { private bool \_autoWidth = true; private int \_columnWidth; public bool AutoWidth { get { return \_autoWidth; } set { \_autoWidth = value; } } public int ColumnWidth { get { return \_columnWidth; } set { \_columnWidth = value; } } } public MultiColumnComboBox() { InitializeComponent(); } public MultiColumnComboBox(IContainer container) { container.Add(this); InitializeComponent(); } }
}
-
That's interesting. Mmm ... so in the code shown below, exactly where are you inserting the [System.ComponentModel.Browsable(true)] please?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace MultiColumnComboBox
{public partial class MultiColumnComboBox : ComboBox { public class Column { private bool \_autoWidth = true; private int \_columnWidth; public bool AutoWidth { get { return \_autoWidth; } set { \_autoWidth = value; } } public int ColumnWidth { get { return \_columnWidth; } set { \_columnWidth = value; } } } public MultiColumnComboBox() { InitializeComponent(); } public MultiColumnComboBox(IContainer container) { container.Add(this); InitializeComponent(); } }
}
As an attribute on the property - in my code:
[System.ComponentModel.Browsable(true)] public string DataItemLabelTitle { get { return this.lblDataItem.Text; } set { this.lblDataItemText = value; } }
It definitely isn't definatley
-
As an attribute on the property - in my code:
[System.ComponentModel.Browsable(true)] public string DataItemLabelTitle { get { return this.lblDataItem.Text; } set { this.lblDataItemText = value; } }
It definitely isn't definatley
Yes, this works for me in your context. But when the property is contained within my class 'Column' it fails. Any ideas would be much appreciated.
-
Yes, this works for me in your context. But when the property is contained within my class 'Column' it fails. Any ideas would be much appreciated.
When you place an instance of your combo box onto the designer window, the Property pane shows the browsable properties of that object. Your 'Column' class isn't a property - it isn't even an instance. What exactly are you expecting to see here? By entering a value in the property pane, what behaviour are you expecting?
It definitely isn't definatley
-
When you place an instance of your combo box onto the designer window, the Property pane shows the browsable properties of that object. Your 'Column' class isn't a property - it isn't even an instance. What exactly are you expecting to see here? By entering a value in the property pane, what behaviour are you expecting?
It definitely isn't definatley
I was expecting to see the additional properties 'AutoWidth' and 'ColumnWidth'.
-
Nice thought. But, however, this did not work for me.
[Message Deleted]
-
[Message Deleted]
I am creating a custom control.
-
I was expecting to see the additional properties 'AutoWidth' and 'ColumnWidth'.
You missed the point I was making - you can only display and change the properties for an instance of a class. What you're asking to do doesn't make any real sense.
It definitely isn't definatley
-
You missed the point I was making - you can only display and change the properties for an instance of a class. What you're asking to do doesn't make any real sense.
It definitely isn't definatley
Your are right (of course). I realise my error now that I have had another jolt of coffee. Thanks for your patience. Mondays ..... :-O