Use Alias Name For Property Of Class?
Apr 21, 2010
I am assigning the class object to grid's data source. And grid displaying all the properties of class with values. But i do not want to display the original name of properties of class. Is there any way to provide set alias name to property to display in grid?
I know that it can be possible by setting the grid's column caption. But i want to do it at class level or by other way instead of processing on Grid. Is there any attribute that set alias name to property?
View 7 Replies
ADVERTISEMENT
Nov 13, 2011
I'm writing custom code in VS2005 Reports (SSRS / Report Builder). The code is working fine, but I have to make absolute references to assembly classes. For instance:For Each m As System.Text.RegularExpressions.Match In ...Is there any way to alias the reference to System.Text.RegularExpressions.Match, so that I can reuse it in a concise manner? I know in PHP, you'd do it like this:
use MyNamespace\MySubNamespace\MyClassVerboseName as MyClass
[...]
MyClass->MyMethod();
[code]......
View 12 Replies
Jun 1, 2012
I have a very simple class that holds a few public properties - ID, Text, Colour, etc. and a Boolean called 'SelectedItem'. Just like the Checked property on RadioButtons, only one item can have its SelectedItem property set to True within a particular group. Note: there will be several separate groups (lists), each allowed to have only one item with SelectedItem = True.
My first thought was that I would probably just have to handle everything outside of the class, setting SelectedItem to False for every other item in a particular list when another item was selected. But that seems rather inelegant to me. So I've been trying to think of how this might be done within the class. For example: could I perhaps have a private string property called say "GroupName" - set in the New sub when adding a new instance of the class - and then use a private shared method to set every item's SelectedItem property to False, provided the item has the same GroupName as the newly selected item? I would have a go at doing this but I have no idea how to enumerate every instance of a class from within that class, or whether that's even possible. Is it? Or is there another (better) way to achieve my goal? Here is a cut-down version of what I've got so far:
Public Class ResourceItem
Public ID As Integer
Public Text As String[code]....
As can be seen: instead of instantiating a new ResourceItem and passing that as an argument to the manager's Add procedure, I'm simply passing the details of the new item and the procedure is creating the item from those. I don't know whether this is a good or bad idea - please advise - but I've done it because I couldn't figure out how to make the SelectedItem property only writeable by the manager, so I wanted to avoid having directly accessible objects that could have their SelectedItem property set to True without it deselecting all the other items in the same group. Of course that still leaves the possibility of setting a variable to one of the manager's list items and setting it from there, so I would still like to know how I could prevent that, if possible.
UPDATE: I didn't use the code above in the end, deciding instead to go with Cyborgx37's solution - which seems to work perfectly well for me despite the warnings about best practice. I also realised I would need to use the same class in another scenario where multiple items could be selected, so it was easy to add a Boolean property to the manager to enable that.
View 2 Replies
Aug 13, 2009
I have the following code:
Public Class MyColorsClass
'Constructors
Public Sub New()
'Empty Constructor
[code]....
However, if the empty constructor was called to instatiate this class then the colortype is not yet set. Therefore, if one accesses the 'IsColorCool' property it will always return 'False'. Now for the sake of this example, I must keep the empty constructor as part of the class.Now I could add some code in the 'IsPropertyCool' to check and see if a ColorType has been defined, and throw an exception if it has not been set, but I don't really want to do that.I also could always move the logic OUT of the property and into a method on the class called 'DefineIfColorIsCool' or something, and make the owness on the caller to make sure the method was called if they want to use the property 'IsColorCool'?
View 5 Replies
Apr 7, 2011
Supose a base class
Public Class airplane
Private var_num_seats As Integer
Private var_num_engines As Integer
[code]....
Obviously, I don't wish that the class Glider has the method "start_engines" neither the property "num_engines". Otherwise, other child classes may have. How can I supress these property and method in child class, not just ignoring (if I can)?
View 2 Replies
Sep 29, 2011
I have procedure (Import) that calls a for a new instance of frmImportData. I also have a class name clsBatch that has a data table property called prpParametersTable.For some reason, I get an error (indicated below with ERROR>>>) when trying to assign prpParameterTable to cv_dtImport2. The error states "Object reference not set to an instance of an object.". Why does this error not happen when I assign dtBP to cv_dtImport1? Both cv_dtImport1 and cv_dtImport2 are equal to Nothing and in my Import procedure dtBP = prpParametersTable.
Public Sub Import(ByVal clsB As clsBatch)
Try
Me.cv_clsB = clsB
[code]....
View 5 Replies
Nov 14, 2009
I have three class files, accounts.vb and transactions.vb in addition to my form.vb. I am unable to retrieve a member variable from on class from inside the other. When the combobox index changes, the program loads the correct account (checking or saving) from two different sequential files. I don't think I have the calcBalance procedure in the correct class file. And that is what I am having trouble with. Accessing it to display it. [Code]
View 1 Replies
Mar 30, 2010
This is a bit of a continuation from a previous post for which AtmaWeapon was very informative.
Problem:
A parent class has a sub class with various properties. A property of the parent class is a List(of T) with T = the sub class The issue is how to store data in the sub class of the instantiated parent
Some example code (hopefully formatted correctly):
Code:
'=========== Class Definitions =============
Public Class courseClass
Public Class timeTableClass
[Code].....
View 7 Replies
Apr 2, 2010
I'm looking for a tutorial on how to Adding a list(of Class) or Collection as another Class's Property.What I am after is something like the Columns Collection for the DatagridView control.I would like to add Items in the graphics screen. Where the item list is displayed in the left panel and the selected Item properties are displayed in the right panel.
View 4 Replies
Apr 7, 2012
I have a class that has the following property that is generated by the methods in the constructor.
Public Class clsLoadTables
Private _ds As New DataSet
Public Property ds() As DataSet
Get
[CODE]........................
My problem is that I do not want to inherit this class, but I have other classes that need to access the ds DataSet property. If at all possible I would like to not use inheritance and not load my datatable more than once in the program.
Here is my failed attempt to access the property inside another class that is not inheriting clsLoadTables:
[CODE].........................
How I can access this dataset that I want to load only once in the program from many classes without using class inheritance or a global module?
View 3 Replies
Jul 29, 2010
I know that an interface can contain another interface within it.But;can a class contain another class within it?Can an interface contain another interface within it?
View 9 Replies
Jul 28, 2010
I have two classes, and for a property in one of the classes I'd like to be able to load it up with an array of the other class. However my attempt at accomplishing this results in a "Object reference not set to an instance of an object" error. I know it's a rookie mistake, but I'm stumpedssist?
My code is as follows:
Namespace Parking
Public Class garage
[code]......
View 2 Replies
Jul 5, 2010
bare with me during this silly example. :-) Let's say I have a class like this:
Public Class Animal
Public iLegs as int32 ' Number of legs
Public bWings as Boolean ' Wings? Yes/No
End Class
And another class that inherits the "Animal" class and adds one more property:
Public Class ScaryAnimal
Inherits Animal
Public iScariness as int32 ' 0-100, how scary is it?
End Class
Now, if I have an instance of "Animal" with some values in it, and I decide I want to cast it to a ScaryAnimal for some reason, how do I do that without having to create a new instance of "ScaryAnimal" and copy each property value?Basically I'm looking for a way to do this, without having to write the lines marked with '*** below:
[Code]...
View 2 Replies
Aug 21, 2011
I am using a sql server database and i am storing the time value in the datetime variable. I am developing a booking system application in vb.net. When I want to view already made bookings using datagridview and by implementing dataadapter and dataset...When the table is shown in the datagridview I want custom column names to be shown so tell me that how can i use alias in the query given in datadapter initialization part?
View 1 Replies
Apr 3, 2012
I have an enum in one module that's used in another that has a long name:
Public Enum Enumwithaverylongname
foo
bar
end Enum
When I use it, I'd like to alias it to a shorter name like:
f.foo
instead of
Enumwithaverylongname.foo
Can I do that?
View 6 Replies
Jan 27, 2012
Here's my SQL query:
SELECT EmployeeID, EmployeeLastName + ', ' + EmployeeFirstName AS Name
FROM employees
ORDER BY Name
How can I go about doing the something in LINQ to SQL?
View 1 Replies
Aug 25, 2010
I have an object and I iterate over object's properties. Foreach property, i append it as a column to a listview.
In my object, some properties doesn't have accents. But in portuguese, they do. For example: "Endereco" property must be "Endereo".
I need an away to create an alias to the properties.
View 1 Replies
Aug 2, 2011
doesn't really matter? low priority.
[Code]...
View 2 Replies
Jun 15, 2010
I am running from a problem while iterating over class properties.
I have my first class:
class Item
private _UIN as integer = 0
private _Name as string = ""
[Code]....
I get UIN, Name, ItemCategory but i expected UIN, Name and Category.
I am a bit unclear about this and dun know why this is happening? What should i do to correct it?
View 1 Replies
May 26, 2010
I have 2 classes and I set a property in class A... how can I get this value within Class B?[code]...
View 3 Replies
Jun 25, 2011
How can I get a string with the name of a property at run time?Obviously using GetProperty, as shown below, is NOT a solution since it requires knowing the property name to begin with:
Imports System.Reflection
Module Module1
Public Class Country
Public Property Capital As String
Public Property Population As Long
[Code]...
What I want is to get the name from an instance (Nation.Capital for example) or from the type (Country.Capital).
View 6 Replies
Feb 24, 2009
I have some VB6 code that I am converting to VB.net and came across this section
Declare Function TmSendByLen Lib "tmctl.dll" Alias "TmSendByLength"(ByVal id As Integer, ByRef msg As Any, ByVal blen As Integer) As Integer
'snip'
[code]....
I have not come across the Alias term before but I can guess what it does. What I am unsure of is the reasoning behind overloading the alias. If that is what is happening.I need to create overloads for the TmSendByLen function as the 'As Any' is not supported in VB.net so I am not sure if I should just remove the alias or if I should leave it in place.
View 2 Replies
Feb 26, 2011
Using .NET (VB or C#), how can I add an e-mail alias to a user in Active Directory? I have written code to change the format of our usernames from "first_last" to "first.last.country" and I need to update the e-mail addresses as well. Our solution is to add an alias e-mail to the users in exchange, but I don't know how I can do this using .NET.
View 1 Replies
Aug 16, 2011
In Reporting Service, I need to have a vertical, starting at bottom, bottom-to-top, horizontally middle aligned text.The only way to do this is to create an image in code, and set this image into the title column.See the code below.Basically, it works fine, just that the anti-alias quality is pretty crappy.Is there anything I can do to improve it ?The vertical text is somehow pale, and not full black, and also there is smearing all around the text, in the background color.As well as it appears bolder than the text on the left, but both have format arial, size 8, bold I've tried all other values of System.Drawing.Text.TextRenderingHint.*, as well as no anti-alias at all but the current one seems to be the least crappy.I've also tried to change the image format, to no avail:
Function LoadImage2(ByVal sImageText As String, ByVal sImageTextMax As String) As System.Drawing.Image
sImageTextMax = sImageTextMax.PadRight(15)
Dim iFontSize As Integer = 8 '//Change this as needed
[code]....
View 3 Replies
Apr 6, 2012
How might one go about aliasing a type in VB.NET or C# such that when the alias is used as an argument type in a function, accidentally using the not aliased type is an error?
i.e.
Imports AccessSpecifier = System.String
Module Accessors
Delegate Function IoOper(ByRef strm As System.IO.Stream) As Action
[code]....
Overall, I'm wanting the IDE to force me to know what I'm doing if I'm throwing Ints around to mean Flags, or States and Strings around to mean Names, Propertys and Records.
View 1 Replies
May 17, 2010
I'm trying to get the Alias of the logged in user (Active Directory/LDAP environment/Exchange) .
View 8 Replies
Aug 13, 2009
I am using a databound datagridview control. I created a custom query to fill the grid with which includes joins and using alias names in the sql query for the joined fields. Here is the query I am using:
SELECT Events.[Date], Events.[Time], Contacts.LastName AS Lastname, Contacts.FirstName AS Firstname
FROM (Events INNER JOIN
Contacts ON Events.ContactID = Contacts.ContactID)
The datagrid views fine using the columns that are in the events table. I want to be able to view the aliased columns from the contacts table in the datagridview as well.
How can I display the joined columns in the datagridview? Maybe there is a better way to do this? Maybe this is not enough information for a resolution.
View 6 Replies
Aug 27, 2011
Private _Order As Order() Public Property Order() As Order() Get Return _Order End Get Set(ByVal value As Order()) _Order = value End Set End Property
I need to get property name 'color' inside the 'order()' array, i am trying ' Order.color ' but its not getting,
View 4 Replies
May 18, 2011
I have the following class:
Class MyClass
Property MyInteger as Integer
Set(ByVal value as Integer)
_MyInteger = value
[code]....
As I'm not using any validation etc in my Property, is there any advantage of using a Property in this case, or would it be neater to use:
Class MyClass
Public MyInteger as Integer
End Class
View 5 Replies
Apr 12, 2009
I have created a very basic class for an object that has nothing so far other than a "name" property.
What I want to do is allow the User to add new properties to the class. Basically all the properties will be strings, but I would like to learn how to generally allow the User to create new properties for the class.
View 1 Replies