Converting Properties from VB to C#


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I'd like to get the following code (from InheritedUI DevEx.TextEdit control) to work in C#:





.Private _ControlSourceUpdateMode As ControlUpdateMode = ControlUpdateMode.OnPropertyChanged

.Public Property ControlSourceUpdateMode() As System.Windows.Forms.ControlUpdateMode Implements IBusinessBindable.ControlSourceUpdateMode

. Get

. Return Me._ControlSourceUpdateMode

. End Get

. Set(ByVal value As System.Windows.Forms.ControlUpdateMode)

. Me._ControlSourceUpdateMode = value

. End Set

.End Property





Here is what I have, so far:





.private ControlUpdateMode _ControlSourceUpdateMode = ControlUpdateMode.OnPropertyChanged;

.public ControlUpdateMode IBusinessBindable.ControlSourceUpdateMode

.{

. get { return _ControlSourceUpdateMode; }

. set { _ControlSourceUpdateMode = value; }

.}





I think that Implements keyword in VB is throwing me off. Can anyone help me with this?



Thanks!!

Bill



P.S. How do I get the copied code to follow the proper indenting after I paste it? I know there must be some trick...I just cannot remember it.

Replies
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
This is related to interface implementation. This property:



string IBusinessBindable.BindingField { get; set;}




is not a property of the control, but of the interface the control implements because you've implemented it explicitly. Try doing this instead:



public string BindingField { get; set;}




and be sure that your class indicates your implementing IBusinessBindable.



Note that one of the IBusinessBindable properties is renamed. IBusinessBindable.DataSourceUpdateMode is renamed as BindingUpdateMode. If you want to do this in C# you'll need to do something like this:



//-- Implement BindingUpdateMode as normal property

private DataSourceUpdateMode _bindingUpdateMode;

public DataSourceUpdateMode BindingUpdateMode

{

  get { return _bindingUpdateMode }

  set{ _bindingUpdateMode = value }

}



//-- Implement DataSourceUpdateMode explicitly, just referencing our BindingUpdateMode property

DataSourceUpdateMode IBusinessBindable.DataSourceUpdateMode

{

  get { return _bindingUpdateMode }

  set{ _bindingUpdateMode = value }

}




Like I said, bruises to my forehead (due to high speed impacts with my desk).
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Ok. Makes sense. I think. Sort of. Kinda.



Here is my adjusted code:





private string _BindingField = "";

[Category(BusinessMod.EDITOR_CATEGORY),

Description(BusinessMod.EDITOR_BINDINGFIELD_DESC),

DefaultValue(""),

EditorAttribute(ControlConstants.EDIT_BindingFieldEditor, typeof(System.Drawing.Design.UITypeEditor))]

public string BindingField

{

get { return _BindingField; }

set { _BindingField = value; }

}





I thought that by using the SF constants that I would be able to see these properties in the control, but they still do not show up. I believe I am missing the boat here somewhere. I haven't resorted to head-bashing (my own or others), but I can see how that might happen.



Bill
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
The properties are accessible from code but not in the designer. What is the trick?
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Note sure. There usually isn't a trick. The designer will show all public properties of your class, unless you tell it not to. So, unless the base class is messing with things, you should be able to see the property in the designer. I usually have issues of it not showing what I want it to show (defaults not setup, editor not setup right, type converters messed up, etc.), but the property is usually there.



Just to check, you do mean that the properties are not accessible when you drop the control on a form right? Because, they won't be if you mean the designer of the control itself. Only the base class properties (and below) are available there.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Interesting. I'll go back to my original plan. Thanks for your help!!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Bill Cunnien - 15 Years Ago
Bill Cunnien - 15 Years Ago
Bill Cunnien - 15 Years Ago
Greg McGuffey - 15 Years Ago
Bill Cunnien - 15 Years Ago
Greg McGuffey - 15 Years Ago
Bill Cunnien - 15 Years Ago
                         This is related to interface implementation. This property:
...
Greg McGuffey - 15 Years Ago
                             Ok. Makes sense. I think. Sort of. Kinda.

Here is my...
Bill Cunnien - 15 Years Ago
                                 The properties are accessible from code but not in the designer. What...
Bill Cunnien - 15 Years Ago
                                     Note sure. There usually isn't a trick. The designer will show all...
Greg McGuffey - 15 Years Ago
                                         Interesting. I'll go back to my original plan. Thanks for your...
Bill Cunnien - 15 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search