.NET Custom Property Attribute?

Mar 6, 2010

How can I shift the GET-implementation of a Class property to a / using a custom attribute? (I've added instantation vars (classname, propertyname) to the attribute, however I'd rather have these automatically fetched ofcourse.)

Public Class CustomClass
<CustomAttributeClass(ClassName:="CustomClass", PropertyName = "SomeProperty")> _
Public Property SomeProperty() as String
Get() as String

[code]....

View 3 Replies


ADVERTISEMENT

Color Property On Custom Attribute?

Aug 4, 2010

i wrote a custom attribute and got the following Color property that I want the user to be able to indicate the color property in the attribute on a class:

Private _ColumnColor As System.Drawing.Color
Public Property ColumnColor() As System.Drawing.Color
Get

[Code]....

View 1 Replies

Retrieve Custom Attribute For Asp.net Checkbox?

Dec 8, 2011

I am using a repeater with the Item Template of a checkbox. Here's my checkbox template:

[Code]...

Now, I know asp checkboxes do not have a value attribute, but I read somewhere that you can put that in there and it will work the same. I'll have to look it up again to see if I read it wrong. However, just in case it is possible to put the custom attribute in there, how do I retrieve it in code behind? I looked at the source after the page is created and there is no attribute in the control that says "value".

View 1 Replies

Specify An Inline Array To Custom Attribute?

Oct 4, 2010

I would like to know if there's any way to specify an inline array (lets say of strings) to custom attribute on a property in vb.net.

I have the following example that doesn't compile in vb.net (.net 1.1):

Attributes.ManyToOne(New String() {"a", "b", "c"})> _
Public Property PaymentTerms() As PaymentTerms

[Code]....

I get compiler error when I feed the array to the custom attribute in vb.net. I have no problem in C#, just vb.net. What is the correct syntax in this silly language?

View 1 Replies

Property Attribute Overloaded 11 Of 11 DefaultValue

Jan 18, 2012

[Code]...

Why is the first line not correct? What it wants is a System.Type and a System.String but refuses to work.

View 15 Replies

.net - Custom Attribute Parameter Of System.Type?

Feb 19, 2012

I'd like to auto-register the common/simple services in my unity container. I think the cleanest way to do this would be via a custom atribute.I can then examine all the (abstract) classes in an assembly and register those types with unity.The piece of information I'm missing is the interface(s) that the class wants to be registered against

eg:

Public Class AutoRegisterAttribute
Public Property ForInterface As System.Type
Public Sub New(ForInterface As System.Type)

[code]....

Note, I don't just want to find any class it implements as shown with IDisposableI've tried doing this using generics (generics can't inherit from Attribute), with a Type Parameter (Passing in IEngine.GetType results in a "Constant expression is required")

View 2 Replies

Add A Custom Web.config Attribute To A Pre-existing Element?

Jan 4, 2012

I have created Custom .NET controls, and I'd like to know if it's possible, how to add a custom attribute in the web.config when you add the reference to the control.

Currently it is:
<controls>
<add tagPrefix="FOO" src="~/Controls/FooControl.ascx" tagName="Bar" />

[code].....

View 2 Replies

Add A Design-time Attribute To A Custom Control?

Jul 29, 2009

setting the default value for an integer attribute of a custom control seems to have stopped working. The following code adds the Maximum attribute to the design-time properties table, but the default value pops up as 0, not 99:

<System.ComponentModel.Browsable(True)> _
<System.ComponentModel.Category("Behavior")> _
<System.ComponentModel.Description("highest value possible")> _

[Code].....

View 4 Replies

Change The TypeConverter Attribute Of A Property At Runtime?

Dec 20, 2011

I have a class created for use with the PropertyGrid control in a VB.Net application. One of the properties of the class is:

Private _someProp As String
<Browsable(True), _
BindableAttribute(False), _

[code].....

View 1 Replies

Store And Then Raise Event In Property Of Attribute

Apr 9, 2009

I think know how to do this in C# but I'm having syntax trouble in VB.NET because I need to take advantage of the 'handles' event stuff. I have different events that I somehow (probably delegate) need stored in a property of an attribute (I just add an attribute to a property linking to the corresponding event).

E.g.
<BindEvent(EventThing)>_
Public ReadOnly Property IsTrue() As Boolean
Get
Return True
End Get
End Property

They need to be events so that other programmers can use the VB.NET handles keyword on methods.
Public Delegate Sub TestEvent(ByVal sender As Object, ByVal e As Object)
Public Event E As TestEvent
Public Sub Test() Handles E
End Sub

These properties are already raising a general event, which I am catching, determining the related property and thus getting the related attribute (and delegate/event). I want to then raise the event that's related. If I just use a delegate tied to the particular event that won't raise other handlers will it? I also want to avoid having to write a sub for each property that just uses Raise Event on the event type if possible as this seems redundant.

E.g. avoid:
Public Event E As TestEvent
Public Sub CallE(ByVal sender As Object, ByVal e As Object)
RaiseEvent E(sender, e)
End Sub
[Code] .....

View 2 Replies

C# - From A UITypeEditor, Retrieve An Attribute Applied To The Parent Of A Property In .net?

Jan 20, 2010

Consider this scenario:

Class MyClass
Property SubProp1
End Property

[code]....

Next, I put an instance of MyButton into a property grid, expand property MC and edit SubProp2.From the type editor for SubProp2, I want to get hold of the attribute applied to property MC.Looking at the context,PropertyDescriptor.ComponentType, we arrive at Type: MyClass.If i look at the attributes applied to MyClass, though, it will only return the attributes applied directly to MyClass, and not the extra attribute applied to the property MC.

View 2 Replies

VS 2005 - Setting Browsable Attribute Of Property At RunTime

Mar 24, 2009

I have done some searching, but am still having trouble trying to set the browsable attribute of property to false at runtime in order to hide in the properties grid control (based on certain conditions).

View 9 Replies

VS 2008 - Retrieve Enum Custom Attribute In Single Statement

Jan 28, 2010

I have an enum set with custom attributes. need to retrieve the attribute value in single statement ...

Public Enum Messages
''' <summary>
''' <value>(MessageText : Do you want to save ?)</value>
''' </summary>
<StringValue("Do you want to save ?")> Save
[Code] .....

Now I needed to retrieve the enum value like something below.
Messages.Save.GetType().GetCustomAttributes...... something is possible in single statement itself?

View 1 Replies

An Attribute Needed For A Property To Instantly Show Changes In DESIGN View

Feb 15, 2010

I have code for a custom DateTimePicker in this thread.>> Do I need to add an attribute to the properties to instantly show changes in design view please

View 8 Replies

Assign Value To Property Of A Class Having Pairs With Attribute Names And Values

Jun 21, 2010

I have valued pairs, attributes names and values in one hand, and I have an object with attributes. I need to set the values of those attributes. I need something like [code]

View 1 Replies

C# - Applying Attribute To Property In Business Object Such That Column Isn't Visible After Databind?

Dec 29, 2011

I was just wondering if it is possible to apply an attribute to a property within a business object (MyBusinessObject) such that after the DataSource of a grid is set to a List(Of MyBusinessObject), the visible property of the column will automatically be false. For example:

myGrid.DataSource = New List(Of MyBusinessObject)
Public Class MyBusinessObject

[code]....

View 1 Replies

Deserializing XML Into Simple .NET Class - Cannot Populate Property From Root Node Attribute

Feb 17, 2010

I have a simple class that I trying to populate from an XML document. The XML file has an attribute called TrackingID in the root node which I would like to get as a property. For some reason, when I deseralize the class, the TrackingID is null. Everything else populates fine. I have tried various attributes on the TrackingID property with no luck.

[Code]...

View 1 Replies

Custom Control With Custom Collection Property?

Jul 11, 2011

I have an ASPX Custom Control which is supposed to load it's properties into an internal collection (defined with PersistenceMode.InnerProperty). Here's the ASPX

<cc:CustomControl runat="server">
<Queries>
<cc:QueryTypeOne ... />

[code]...

View 1 Replies

Property Editor For Custom Property Is Disabled?

Jun 16, 2009

I have a problem with a property on a custom property of a class. Here is the actual code for the inherited form

Public Class Form : Inherits System.Windows.Forms.Form
Private _Active_Application As Custom.Classes.Active_Application = New Custom.Classes.Active_Application
<System.ComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableState.Always)> _
Public Property Active_Application() As Custom.Active_Application

[code]....

but when i use a separate class to inherit the above class this property ('Active_Application', not Custom.Classes.Active_Applicaton) is disabled.

View 1 Replies

C# - RefreshProperties Attribute At Class Level In .net, Winforms + Incorrectly Refreshing Property Grid?

Feb 15, 2010

I had a strange problem editing a class in the property grid whereby the property grid would refresh incorrectly.I managed to reduce the problem down to a class with just two properties. I've included the code at the end to ease explanation.It basically boils down to a class with two properties. The first of which is expandable (a font)The class itself is expandable and also implements the CreateInstance method in the type converter.To see the problem, expand the font, edit, say 'Bold', and tab away. Two problems happen:

(1) The second property jumps up and ends up in the expanded font property.

(2) The '-' sign of the expanded font changes to a '+'.

The problem goes away by attaching ResfreshProperties(RefreshProperties.All) to the class. That's great, but I'd like to understand how it fixed the problem. I've had a look in reflector and can't find any examples of RefreshProperties being attached at the class level.

[code]...

View 1 Replies

Reading 'object-attribute-attribute Value' Triples From Column-based CSV Files

Nov 27, 2011

here any algorithms/pseudocode for reading/parsing 3-column csv data and determining unique objects/attributes/values?

example data:

john,height,1.75
george,age,21

[Code]....

i have already implemented a solution of my own but it's too slow and i can't find any relevant literature on the internet.

View 6 Replies

Unrecognized Attribute 'targetFramework Note That Attribute Names Are Case-sensitive?

Nov 10, 2011

Possible Duplicate: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive

I am using window xp and iis 5.1 to run the application.

error is occurred Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.

[Code]...

View 2 Replies

'SSLAccessFiltercannot' Be Used As Attribute Because It Does Not Inherit From 'System.Attribute'

Feb 2, 2012

I get an error when I try to build my project.'SSLAccessFiltercannot' be used as an attribute because it does not inherit from 'System.Attribute'. [code]

View 1 Replies

Add A Custom Property Trigger?

Dec 21, 2009

I am using Expresion Blend 3 and created a new user control in my project. I want a storyboard to run if a custom property of that user control is triggered like with the ones shown here in the list..

I learnt you need a dependency property, but my understanding there is limited. Here's the basic code I set up with property "IsAwesome" as an example[code]...

View 1 Replies

Add Property To Custom Control?

Apr 3, 2010

I have created a custom class, which contains a panel and a label on it. I added to this class a pcaption property, which holds the label text. This property is browsable and I can change its value.But when I drag the custom control to the form and change the pcaption property, it has no effect. Even the <Defaultvalue> has no effect. Why?

Here is the class code:

Imports System.ComponentModel
Public Class mypanel
Inherits Windows.Forms.Panel
Private panelcaption As String

[code]....

Color values are unimportant, you can change it.

View 3 Replies

Can't Access Custom Property?

May 15, 2010

I created a new DataGridViewColumn type called DataGridViewGradeColumn.

Public Class DataGridViewGradeColumn
Inherits DataGridViewTextBoxColumn
Public Property AssignmentName As String

[code].....

View 1 Replies

How To Get Custom Property Of Form From Another One

May 11, 2010

I have two forms, say Form1, Form2
Form1 has one textbox and one button, Btn1 when clicked, it opens Form2 as dialog.
Form2 has one textbox and one button too.
First I click on Btn1 to open Form2 as dialog. And when I click on Btn2 on Form2, I want the text in the Textbox2 to be copied to TextBox1. I know it could be done by Public Property Get, Set but I am stuck.

View 7 Replies

Make Custom Property?

Mar 10, 2009

this is the code for my property

Dim _playernumber As Integer
Property Player() As Integer
Get

[code].....

View 3 Replies

Add Property For Custom Control In VS2008

Jul 2, 2009

I am developing a custom control with VB9, and I want to add a Property Name TextFileName this property need to use OpenFileDialog, which type I can use when I define this property?

for example another property I use is EnterFocusColor and its type is System.Drawing.Color so when the user select the property it opens the ColorSelectionDialog Hany M. El Tarhony

View 1 Replies

Add Validate To A Custom Class Property

Mar 20, 2011

I'm trying to add validation to one of my class properties:[code]The value for the golfer's handicap comes from a oombo box on the form. Even if I have nothing set for this property at runtime, my validation doesn't work. I tried putting the If statement under Get instead of Set, and tried mHandicap = value after an Else in the If statement, but nothing seems to work. I'm working in the dark here and can't find anything suitable online. I was hoping to not go down the path of ReadOnly or WriteOnly properties as I'm not at that stage yet, but does this make a difference for my purposes here? Can anyone guide me as to what I'd need to do from this point? If I've got it right, you can add validation in the class and this means that you then don't need to repeat this validation in the form??

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved