C# :: Abstract Classes And ReadOnly Properties?

Jan 12, 2011

Let's have three classes;

Line
PoliLine
SuperPoliLine

[code]...

View 3 Replies


ADVERTISEMENT

.net - Setting ReadOnly Property In PropertyGrid Sets All Properties Readonly?

Jun 12, 2012

I am using a PropertyGrid control to edit my class properties and I am trying to set certain properties read-only depending on other property settings.This is the code of my class:

Imports System.ComponentModel
Imports System.Reflection
Public Class PropertyClass[code].....

This is the code I am using to edit the values:

Dim c As New PropertyClass
PropertyGrid1.SelectedObject = c


The problem is that when I set SomeProperty to True, nothing happens and when I then set it to False again it sets all properties Read-Only.

View 1 Replies

Asp.net - Use Abstract Classes In A 3-tier Solution?

Feb 1, 2012

My immediate issue is that currently I have a 3 tier solution (Presentation.aspx.vb calls BusinessLayer.vb which calls DataAccessLayer.vb). However, I want to make BusinessLayer and DataAccessLayer.vb abstract classes because several Webforms will use have the same functionality.

So I currently am doing this (no abstract classes):

'Presentation Layer (pseudocode)
public sub checkUser(byval userName as string, byval dept as string)
dim isGood as boolean = BL.checkUserAccess(userName, dept)

[Code].....

View 1 Replies

Pros And Cons Of Using Abstract Classes

Nov 18, 2010

I have been reading up on Abstract classes and am thinking about utilizing them in an upcoming project.

I would like to know the pros and cons of using abstract classes from someone who has actually used them.

Additionally, I would like to know if the abstract class needs to be in it's own project or if they should be defined in an existing project and used within the application.

View 1 Replies

Use LINQ To Filter Collection Of Nested Classes To Yield Dictionary Of Unique Properties Of Those Classes?

Jan 23, 2012

I have two classes, one nested in the other. [code]Neither "Name" or "ID" are unique between operations and records.I wish to construct a dictionary using LINQ = Dictionary(Of String, Of List(Of Integer), whereby the keys are uniqe examples of Names in my collection and the values are the collective set of distinct IDs that are associated with those names.

View 2 Replies

.net - Use Readonly Property Across Multiple Classes?

Jun 7, 2011

I have created a read-only property(name) in class1. How can I use this name property in class2?

Public Class Class1
ReadOnly Property name() As String
Get[code].....

Can I directly carry this name variable value into class2?

View 3 Replies

.net - Listing Properties / Checking If A Property Is ReadOnly

Nov 26, 2009

I'm faced with a couple of problems in VB.net: I have a series of objects, which properties I'm displaying in a grid for the user to edit. My first problem is: how do I get a list of all the properties of an object? Is it even possible? The datagrid control that I'm using accepts string values with the name of the property as parameters, but inserting them manually would be a real problem, because there are a LOT of them. So: is there a way to get a list of strings with the name of each property of an object?

If that's possible, here comes the second question: Now, of course, since users are editing the properties, I'm not interested in showing ReadOnly properties which they cannot edit. Hence my secodn problem: is there a way to check if a property is readonly at runtime?

View 2 Replies

Creating Instances Of A Class That Has Several Readonly Properties?

May 24, 2011

What is an elegant way to create and initialise instances of a class that has several readonly properties? Passing all values in a constructor would not be very convenient.

The purpose is that instances are immutable after initialisation. However if the constructor is not used for initialising all the property values, then how can the readonly properties be changed from another class?

View 2 Replies

Copying A Set Of Private Variables Into Corresponding Public ReadOnly Properties?

Oct 18, 2011

I have a bunch of private variables I've typed out and I want to put all of my corresponding Public ReadOnly Properties in a bunch below them.Is there some way of copying ten lines of

Private _myVar As String

and pasting in ten sets of

Public Readonly Property MyVar As String
Get
Return _myVar[code]....

I'm currently copying the whole bunch of variable declarations, Find+Replacing Private _ into Public ReadOnly Property then going line-by-line expanding the definitions and writing return statements.how to avoid all this nonsense in the future, as I'm developing on a virtual terminal server, and the input lag on my little copy/paste/type operations on the code is driving me up the wall.

View 1 Replies

ReadOnly Properties - Test For A Right/equilateral Triangle In My Get Accessor?

Apr 13, 2009

I'm designing an application for a class where the user inputs three values and the program tells them whether it is a right triangle, equilateral triangle, or neither.I'm trying to figure out how to test for a right/equilateral triangle in my get accessor.... Here is the code so far for the class:[code]......

View 1 Replies

Visual Studio 2008 - ReadOnly Properties/Functions In .Net?

Sep 28, 2010

I'm working on rewriting something in VB that was previously in C# and while I was doing so, I came across a "dilemna." I can have a ReadOnly Property:

Public ReadOnly Property MaximumIndenture()
Get
Try
'If the connection is closed, open it.'

[code]....

They both essentially do the same thing, but I'm not sure which would be more accepted in the community.

View 3 Replies

Loop And Enumerate Properties Of Nested Classes In Nested Classes?

Sep 24, 2010

so far i got

code
For Each item As Reflection.FieldInfo In GetType(NameSpace.ClassWithNestedClasses).GetFields
rtfAppend(item.Name & ":" & Tab & item.GetValue(Me))
Next
For Each item As Reflection.PropertyInfo In GetType(NameSpace.ClassWithNestedClasses).GetProperties()

[code]...

which gets me the simple string vars and properties of my top class, but how can i apply this to loop through all sub classes and get there vars and props?

View 1 Replies

Access Properties Of Form Classes?

Oct 21, 2009

I have Form Class A, which is the "Main Form". An Event fired by Form A instantiates Form B, and sets Form A as it's owner. (which makes it be on top of FormA at all times)[code]...

View 4 Replies

Accessing Properties Of Form Classes?

Feb 4, 2010

Accessing Properties Of Form Classes

View 1 Replies

Suppressing Properties In Inherited Classes?

Dec 3, 2008

Seems like you should be able to Suppress Properties in inherited classes. How do you do it?

View 7 Replies

[2008] Properties/classes And Generics?

Jan 9, 2009

what I would like to do is create a class that has a few private properties and one public property.the end result of the class is to return a list(of servers)below is what I am thinking. My brain just can't come up with the correct answer.

namespace sample
Private _servername As String
Private _farmname As String

[code].....

View 1 Replies

C# - Restrict The SchemaAttribute To Classes And The AttributeAttribute To Properties?

May 21, 2010

I have two custom attributes defined like so:

internal class SchemaAttribute : Attribute {
internal SchemaAttribute(string schema) {
Schema = schema;

[code]....

I would like to restrict the SchemaAttribute to classes, and the AttributeAttribute to properties.Is this doable?

View 2 Replies

Dynamic Properties For Classes In Visual Basic?

Feb 27, 2009

I am a vb.net newbie, so please bear with me. Is it possible to create properties (or attributes) for a class in visual basic (I am using Visual Basic 2005) ? All web searches for metaprogramming led me nowhere. Here is an example to clarify what I mean.

public class GenericProps
public sub new()
' ???

[Code].....

View 3 Replies

Instance A Class, Based On Other Classes, Add New Properties?

May 26, 2009

You know how everyone says "C++ is like C with classes"?How similar is it to .NET classes? instance a class, based on other classes, add new properties, override existing properties, etc?Are the variables strongly-typed and declared before they are used? Or is it a Duck-Typing language like Python?

Also, does it have its own Garbage Collector that disposes of objects when the pointer exits their scope,or do you have to manually clear and get rid of them when you finish with them? What's the difference between native C++, and the "managed C++" in Visual Studio? Because I'd prefer to use native code if its not too much harder. for the sake of all that is good and holy, don't use ACCESS, EXCEL, or a TEXT FILE as a database. If you want your program to use a "local database", without any of the hassle of setting up a MS SQL or MySQL server, just click this link: >>> SQLite <<< Seriously. This is for your own good.

View 3 Replies

Make Subroutines / Properties Inactive In Classes?

May 27, 2010

I am working on a bitmap class module in Visual Basic 2010 that has an option to create a graphic grid on the bitmap.

[code]...

View 3 Replies

VB Classes Best Practice - Give All Properties Values?

Mar 16, 2010

Sorry if this is a bit random, but is it good practice to give all fields of a class a value when the class is instanciated? I'm just wondering if its better practice to have a constuctor that takes no parameters and gives all the fields default values, or whether fields that have values should be assigned and others left alone until required?

View 4 Replies

Is This Workaround/architecture Correct Using Classes (complex Properties)?

Feb 15, 2012

what's a Class, and Object, a Method, a property and thins like that, but I have this doubt:Let's supppose I have a class "Laundry" this class has (just for this example) 3 propierties:

1.- laundryID
2.- Name
3.- Washers

Id and Name are "primitive" types or simple types (integer and string), but Washers, represent a list of object of type "Washer", that has 3 properties:

1.- washerID
2.- laundryID
3.- capacity
4.- brand

All of them (for this example) simple/primitives types (integer,string,string).So this my dilemma, it is correct to have a constructor like this (VB .net)

public sub new(ByVal laundryID as integer)
'' Here I'll query for the data of the Laundry on DB
'' After that I will query for every washer that belongs to this laundry

[code]....

And inside of that constructor query for all the washers that belongs to the laundry with id=laundryID parameter, and create objects of type "Washer" and add them to the list of Laundry ?I'm not sure If I explain myself, any comment I'll be really grateful, in less words, what's the correct approach (or good practices) to work with class/objects that has properties which are complex (other class/objects).I usually work with ADO.net probably ADO/LINQ/Entity solve this thins in an transparent way, but if they do it I don't really know it.

Note: I'm familiar with VB.net, C#, PHP, so if you prefer explain/help me using examples with its syntax, it's ok

View 2 Replies

Amend Readonly Properties - Like Font.underline - Font.height

Nov 16, 2009

How do i amend the read only properteis like font.underline, font.height etc I know its read only but there must be a way to amnd these.

View 4 Replies

Design Patterns - Inheritance - Do All Properties In The Derived Classes Have To Be Declared In The Base Class

Aug 8, 2011

Background:I have a base class and several inherited derived classes. The derived classes don't always need to have the same properties. If any properties are shared among the derived classes, those properties would live at the base class level ('Contents', for example).Similarly, GoodDocument below has 'GoodThings' but would not want/need to have 'BadThings'.I want to treat instances of both 'GoodDocument' and 'BadDocument' as type 'Document'

public mustinherit class Document
public property Contents as string
public sub new()...

[code]....

View 3 Replies

What Are Classes , Objects , A Namespace , Subroutines,functions,methods,properties And Difference Between Byval And Byref

Jun 26, 2010

I want to know what are classes , objects , a namespace , subroutines,functions,methods,properties and differemce betweem byval and byref in your words.

View 18 Replies

Nest Classes But Properties "inaccessible Due To Protection Level"

Oct 7, 2011

I am trying to implement a sub-class as a property of another class. Eg:

[Code]...

View 9 Replies

VS 2010 Structure Classes So That The User Interfaces Though A Single Class While The Supporting Classes Are Hidden From Their View?

Jun 13, 2012

How can I structure my classes so that the user interfaces though a single class while the supporting classes are hidden from their view? I think its best understood in an example:

Public Class MyInterface
Public Economic as EconomicClass
Public Sub New()
MyBase.New()

[code].....

So you might ask why am I even separating them? It's strictly for others who will be working with this interface. I need to funnel them though a logical structure:

interface.Economic.MyMethod
interface.Currency.MyMethod
etc

This way everything is already handled for them in the background and they only need to run the method they need. I don't know if I can have it both ways in VB.NET.

View 23 Replies

VS 2010 Calling Subs And Functions Within Classes That Are Within Classes?

Oct 24, 2009

Here is some example code of what I mean:

vb
Public Class Form1
Private Sub Button1_Click(ByVal sender as Object, e as systemEventArgs) Handles Button1.Click

[Code]....

View 5 Replies

Using Dll In C++ - Class Is Abstract?

Jan 6, 2010

I created a vb.net dll which I am using in an unmanaged c++ project.When I try to create an object of the class, I am getting an error:cannot instantiate abstract class.Why would my class be abstract? How can I modify it so that it won't be abstract?

View 1 Replies

Abstract One By One Numbers From The Textbox

Sep 29, 2009

I am doing a project on abstract the numbers that i get from the datagridview to append it on the other textbox. Ok I elaborate more. I have 2 form which is form1 and form2. For the form1, the view is 2 textbox and a 'To' button. when click on the 'To' button, it is direct to form2 which is the datagridview. After selecting the selected numbers, it will display the numbers on the form1 of the one of the textbox. but the problem is I want to abstract one by one of the numbers and append it on the other textbox of the form1.

View 9 Replies







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