Click here to Skip to main content
15,897,891 members
Everything / Properties

Properties

properties

Great Reads

by Tomaž Štih
Simple trick to implement csharpish properties in modern C++
by Dev Leader
With this post, we’re still just scratching the surface of what’s doable when integrating Python and C#.
by ASP.NET Community
LoginStatus control is used to display Login /Logout links based on the login status of the current user.If the user logged in it displays Logout ,if
by ASP.NET Community
The CompareValidator control compares the value of one control to another, or to an explicit value in the control's ValueToCompare property.

Latest Articles

by emartinho
A Java String property value starting with a single number (e.g., a CRON schedule like "0 30 */1 * * ?") is truncated to just the first number.
by Tomaž Štih
Simple trick to implement csharpish properties in modern C++
by Jin Vincent Necesario
In this article, we'll explore the world of C# attributes.
by Sandeep Mewara
Issues faced while setting up Kafka on Windows OS and how I resolved it

All Articles

Sort by Score

Properties 

25 Oct 2020 by Tomaž Štih
Simple trick to implement csharpish properties in modern C++
1 Oct 2013 by Dev Leader
With this post, we’re still just scratching the surface of what’s doable when integrating Python and C#.
17 Jun 2013 by Sergey Alexandrovich Kryukov
Historically, the second approach was created first, and only later the semantically equivalent syntax of auto-implemented properties emerged. The benefit of this new syntax in development looks quite apparent, let's not discuss it.Let's discuss only the potential name conflict you just...
6 Feb 2015 by Zoltán Zörgő
In second you create an instance of first. I third you create an other instance of first. These are two different instances. The property is not static, thus every instance has a different memory space allocated for it. Sou either share one single instance or use static property.But I can't...
17 Jun 2013 by Ron Beyer
"Proper" use is pretty subjective, there is no hard rule on this.What I do is typically use auto-generated backing fields for my metadata classes. These are classes that do not have any code (or very little serializing code). The bigger more involved classes I usually implement them...
21 Jul 2013 by Sergey Alexandrovich Kryukov
ThePhantomUpvoter is right (I refer to his comment to the question): this is not a valid question, and the code sample is irrelevant to properties. But I wan to make one general note: these days, one absolute fallacy became very typical for the beginners: a string is taken as some universal data...
9 Sep 2013 by Menon Santosh
check this articlehttp://stackoverflow.com/questions/11676176/iterate-through-class-properties-to-get-child-class-values[^]
11 Oct 2013 by ASP.NET Community
LoginStatus control is used to display Login /Logout links based on the login status of the current user.If the user logged in it displays Logout ,if
14 Nov 2013 by Sergey Alexandrovich Kryukov
First of all, to work with FTP as a client, you will need to use the class System.Net.FtpWebRequest:http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest%28v=vs.110%29.aspx[^].Then you will need to use proper System.Net.FtpWebRequest.Method. Please...
29 Nov 2013 by BillWoodruff
I've gone back over your original question and realized I didn't understand what your goal is here. Here's a working template you can use to experiment with ... hopefully learn from.The challenge, in this case, is interesting: you are kind of "bending" the RadioButton to a task it wasn't...
4 Nov 2014 by Sergey Alexandrovich Kryukov
There is nothing wrong with your code. Your problem is the matter of general design of your code. You hardly can find any miracle technique or design pattern, because the basic idea is very elementary, and your problem with cross-dependent properties is way too specific to the way you personally...
1 Apr 2015 by Sergey Alexandrovich Kryukov
Before re-posting the question (or posting very much related question), you should have seriously think at my answers you already got:How to get response when click PropertyGrid,How to show values for custom property during desgin-time C# WPF?.In addition to that: as you want to "add the...
20 May 2015 by Tomas Takac
From your explanation I understand you are able to map a clientID to a property. It still feels like magic and it's possible that I'm missing something but let's assume you can do the translation.Your idea about building a dictionary is correct. It should be a dictionary of...
25 Jul 2017 by Graeme_Grant
If the VB code is in a class library, then you can reference and use it like you can a C# class library. Here is a test to show how this works: 1. Add a C# Console app to a solution 2. Add a VB class library to the solution 3. reference the VB class Library in the C# console app 4. use the...
22 Nov 2021 by Maciej Los
Well, i'd suggest to move data biding into ucSignGen. Imagine, you can easily set/get an object related with UserControl. All you need to do is to create custom property: partial class ucSignGen { private SignalGenerator SigGen = new...
21 Jul 2013 by H.Brydon
First of all, don't update your question by adding something as a solution.I have not spent a lot of time in either of the C# or VB.NET worlds, but am a bit confused with the code. The constructors are not consistent. It doesn't seem to be the same between the C# and VB.NET versions... but...
2 Sep 2013 by OriginalGriff
See here: http://stackoverflow.com/questions/1503976/determine-if-property-is-generic-listof-t-via-reflection-and-loop-list-items[^]About half way down is a complete console app which should do what you want.
11 Oct 2013 by ASP.NET Community
The CompareValidator control compares the value of one control to another, or to an explicit value in the control's ValueToCompare property.
2 Dec 2013 by Mike Meinz
One way lets you have validation or other code in the property set/get. The other way simply sets or gets the property with no additional code.The Microsoft Help file explains the differences:Using Properties (C# Programming Guide[^]Properties have many uses: they can validate data...
7 Feb 2014 by Grant Weatherston
Hi i've took over from a developer in our company and i've come across a jS file, it declares var requiredTemplates = {};at the top of the page, and then later on doesrequiredTemplates.toolBarTemplate = new Application.Template() *custom classrequiredTemplates.uploadTemplate =...
25 Mar 2014 by Raul Iloc
The message occurred because you are using German version of Visual Studio, and you are trying to input value in English.If you are using German version of the Windows, and your software is designed to be installed only in Germany make no sense to use numbers in English format, but if not...
11 Feb 2015 by nirav raval
Module 1:ObservationCollection lstVariable = new ObservationCollection();Module 2:public ObservableCollection variableData { get { return _varialbleholder ; } set...
31 Mar 2015 by Sergey Alexandrovich Kryukov
Member 10794476 asked:I am able to do it as enumeration and it is static. If I want to generate the property values programatically at runtime, what would be the best possible way to do it?There are two different questions here, second one depends first, but first is unrelated to...
27 May 2015 by Sascha Lefèvre
The GenerateMember, Locked and Modifiers properties are design-time only properties. They are listed in the Properties-page among the real properties but they are actually only used by the Form Designer / Visual Studio. So there simply is no class-property that could be hidden like you did with...
10 Aug 2017 by BillWoodruff
The compiler is telling you that it has not completed compiling the Class, and the Method body you try to reference is not available. Create a Constructor for the Class and set the reference to the Method there: public partial class ScreenShotConfigurationForm : Form { private const int...
8 Dec 2012 by mibetty
Hi..Im doing a form in visual studio!but i have a problem i changed the backColor of my form to a color that isn´t in visual studio system.And now i have my labels and buttons with default color of the form.How can i put the backcolor of labels and buttons icual than form backcolor?
8 Dec 2012 by cigwork
Do you mean that you want to reset the backcolor of labels and buttons on your form to the "default" colour for your machine but have a custom colour for the form background?If you do then for each button on the form go to its properties and for the BackColor property select the System tab...
10 Dec 2012 by exposed12
Hi,I ve got the following problem:Within my csproj I use a variable, I ve declared in an external properties file. To reference it, I ve imported this properties file.properties file:
10 Dec 2012 by exposed12
In the meantime I ve solved the issue.The problem was, that my current user has full Admin-rights but msbuild was executed in a lower role => environment variables setup by Admin could not be solved by the normal user.Fazit: strange behaviour and almost impossible to get on the ground of...
17 Jun 2013 by jeramyRR
I've read quite a few great articles on CodeProject where the author declares properties in the following manner:public class TestClass{ public string FirstName { get; set; } public TestClass() {...} ...}Notice that the FirstName property is declared with...
17 Jun 2013 by Bernhard Hiller
When it is such a simple situation like the one you described (just get and set without any extras), I prefer the short style.But sometimes, some extras are required, mainly with the setter: e.g. checking for a valid value (not null, bigger than x, smaller than y, ...), or firing a...
19 Jul 2013 by Woogie2
What I was missing here was that I needed to a) declare a property called Objectives as a collection/list of Objective b) set up a call to populate the objectives and c) set up a sub topopulate objectives using a query restricted to that projectIDThe data layer tutorial proposed by Maciej...
2 Sep 2013 by emrebeysungu
Hi everyone,I have a class which has primitive type properties and also has types like List of something.At this code: string[] colums = typeof(T).GetProperties().Select(c => c.Name).ToArray();foreach (var col in colums){ var tc= typeof(C).GetProperties().Select(c =>...
2 Sep 2013 by abbaspirmoradi
you can get type of propety with:System.Reflection.PropertyInfo propertyInfo = typeof(ObjectName).GetProperty("propertyName");Type type = propertyInfo .PropertyType;
26 Sep 2013 by Acusu
Hi everyone!!I want to return different values in a property,according to the method that reads it.Thanks beforehead.
26 Sep 2013 by Mehdi Gholam
A bad idea like Richard said, but you can use the StackTrace see here : http://stackoverflow.com/questions/615940/retrieving-the-calling-method-name-from-within-a-method-c[^]
2 Oct 2013 by ICEFLOWER2
I Find it:[VB] Private TargetValue As String _ Public Property Target() As String Get Return TargetValue End Get Set(ByVal value...
8 Oct 2013 by Dragonranger
A way to add automatic properties to the FormCode for InfoPath 2007.
11 Oct 2013 by ASP.NET Community
Nearly all the controls in ASP.NET have properties that can be databound to.ArticlesJesse Liberty has a fine article on Data Binding in ASP.NET
11 Oct 2013 by ASP.NET Community
ProfileThe Profile provider stores information on a user defined by the profile properties in the web.config. By default the properties are
11 Oct 2013 by ASP.NET Community
The RangeValidator control tests whether an input value falls within a given range. RangeValidator uses three key properties to perform its
11 Oct 2013 by ASP.NET Community
The CompareValidator control compares the value of one control to another, or to an explicit value in the control's ValueToCompare property.
11 Oct 2013 by ASP.NET Community
The CheckBoxList control creates a multiselection checkbox group that can be dynamically generated using databinding. To specify items that you want
11 Oct 2013 by ASP.NET Community
Every element in the configuration file maps to a class in the .NET framework.  It's possible to expand upon this to create custom configuration
11 Oct 2013 by ASP.NET Community
The TargetControlID is one of the key properties with the AJAX Control Toolkit.  Being a property defined on the control extenders, this property
11 Oct 2013 by ASP.NET Community
It's now possible to create class definitions on the fly.  This is the concept of anonymous types, where the type is based on the signature of the
11 Oct 2013 by ASP.NET Community
What is Access Modifier?Objects in .NET are created from a class, struct, etc.  Thesedefinitions, as well as the properties, methods, or events
11 Oct 2013 by ASP.NET Community
Always Visible Extender Control of Ajax is used to show some control (a panel mostly) on the page always. By always, it means that if the page has
11 Oct 2013 by ASP.NET Community
ThemesAuthor: Prakash Singh MehraIntroduction: Themes are the way to define the formatting details for various controls and can be reused in
18 Oct 2013 by Rahul Krishnan R
Hi,when the window state property of a form is set to maximized, it overlaps the task bar when we run the application.I don't want the task bar to be hidden and the application should run normally like other apps.Please give a solution to this.Thanks
18 Oct 2013 by Rahul Krishnan R
Hi,I managed to solve it by adding the below code in the load event of the form this.Size = Screen.PrimaryScreen.WorkingArea.Size;Thanks
14 Nov 2013 by Umer Asif
Hi,How can i read File Properties via FTP without downloading it ?Thanks for your Time.Regards.
2 Dec 2013 by M.Azeem BAig
This is a property which is encapsulated below:int _CategoryID; public int CategoryID { get { return _CategoryID; } set { _CategoryID = value; } }and...
2 Dec 2013 by Beorne
I'm using Visual Studio 2008 SP1 and it hangs when i click on a DataGridView. Making some experiments I found that If I close the properties window it does not hangs, but if the properties windows is open (or if i reopen it) it hangs up.It did function all ok up to some time ago, when I...
20 Jan 2014 by hansoctantan
Hello everyone, I'm creating my first User Control, an Image Viewer. I have a property Image (String), this works fine but not user friendly. You need to key the whole path or copy and paste the path. Can someone suggest me a code that browse all images file as a property. ...
20 Jan 2014 by Sergey Vaselenko
See OpenFileDialog[^] example on MSDN.You should specify the Filter property to allow select image files only.In your case you may use the FileNames property to get the selected file names.
7 Feb 2014 by Maarten Kools
They will be created on the fly. An alternative notation would be obj[key] = value.They are not really associative arrays actually. It's an object with properties, so you won't be able to use it in the same way you would use an array (e.g. for (var i = 0, len = obj.length; i
26 Feb 2014 by rezaasaadi
I have a MFC ActiveX VC++ project that create a control to use in some VC# .NET projects.Why I didn't use .NET user control to develop this control because GDI is faster than GDI+ in drawing what I want this control shows.The control works well when it connects to database.Now I want it can...
26 Feb 2014 by Garth J Lancaster
You would 'generally' (because there's always an exception') use COM Interopiirc there's a tool called tlbimp that generates a 'wrapper' for you - see if this helps :-http://examples.oreilly.com/9780596527570/COMIntegrationC%23Nutshell2ndEd.pdf[^]If that's no use, do a search for C#,...
2 Mar 2014 by Member 10455358
How do I set a buttons image, and link properties from a text file of spreadsheet ?so that when the program runs it installs the setting at the startthank youdave
5 Mar 2014 by agent_kruger
how to hide file location of a folder shortcut like in the picture belowhttps://www.dropbox.com/s/njamem76utmxof1/Ask1.png[^]as in the 2 pictures one denotes a shortcut of a game "Dota 2" and other picture is of a shortcut of a folder. In 1st picture a person hid his location of the file....
5 Mar 2014 by OriginalGriff
Um.You did notice that one of them is a shortcut (i.e. a .LNK file) , and the other is a .URL file?They aren't the same thing...
6 Mar 2014 by RAHUL(10217975)
Hey All,I am working on windows application. To know whether the application is used for the first time I am using Application property bool by default value is false and when application executes its became true asProperties.Settings.Default.FirstTime = true; ...
25 Mar 2014 by lukeer
Hi experts,we all know how to store application configuration data in app.config using the "Properties" tab of a project's properties. Today I tried to store a float there, changeable by user.Upon entering 0.2 I am confronted with an error message saying that "0.2" cannot be converted to...
10 Apr 2014 by hansoctantan
Solve itAdded code to Property and Reference System.DesignImports System.ComponentModel
7 May 2014 by inam2001
namespace Testing{ public partial class Test : Window{ private static Test _instance; public static Test GetInstance(){ return _instance; } public DateTime LastHitTime { get; set; } System.Windows.Threading.DispatcherTimer timer1 = new...
25 May 2014 by rakeshjena
why my set block is executing multiple times when i assign value to my propertymy code is--------using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace practice{ class Program { public static...
25 May 2014 by OriginalGriff
Well...yes - it will... public static int eno { get { return 1; } set { eno = value; } }Soeno = 5;Calls the setter, which does:int value = 5;eno = 5;Which calls the setter,...
30 May 2014 by Member 10854371
I'd like to add a property to my custom control, that uses a combobox editor, populated with the names of other controls in it's parent.I already have an arraylist, or string(), containing the names of the controls to be populated but what's the best way of going about this.I understand...
31 Jul 2014 by Member 10401272
Hello everyone,I have a problem with my Code. Some classes shouldn't be possible to write in propertys but some classes should be able to write and read them.Problem in detail:I coded the invoice in the Controller as private set, so i can only set the invoice in this class. that is...
31 Jul 2014 by Ziee-M
hi, you have to remove either the setter or the getter.class InvoicePosition { private string name { get; set; } //switch the visibility to private, and the name //start with lowerCase //same with this variable private double price { get; set; } //same...
3 Aug 2014 by Member 10901644
I am using this code to show user profile propertiesvar currentUserId = User.Identity.GetUserId(); var manager1 = new UserManager(new UserStore(new ApplicationDbContext())); var currentUser =...
3 Aug 2014 by Boudi AlSayed
I'm trying to to change a textbox text when a read-only property changes... I don't have access to the property source because it is from an external library. I just want to check whenever the code changes a Boolean property for example, like events, do something when this event happens. if the...
6 Aug 2014 by Jaimin H. Soni
confusion arise from the fact that we create the UserManger in one line like this:var currentUserId = new UserManager(new UserStore(new MyDbContext()));then we use currentUserId .UpdateAsync( user ); but that will update the user in the context and then we will need to savechanges to...
7 Aug 2014 by Member 10901644
I just deleted this code and everything is working fine now thanksprotected void Page_Load() { var currentUserId = User.Identity.GetUserId(); var manager1 = new UserManager(new UserStore(new ApplicationDbContext())); ...
8 Aug 2014 by Maciej Los
Here[^] is a collection of events for Visio. Try it!
10 Sep 2014 by CPallini
You, as developer, are supposed to know that.Check out a good book on Object Oriented Programming and become a master.
10 Sep 2014 by xackt
That is not an appropriate answer according to my question -_- ...I am a lead developer of VB.NET ...but need professional designer for a company...thats why i am asking :/
30 Sep 2014 by Davester28
I get this error at runtime, but not while debugging F5 style...Error occurs when closing this form, which is an MDI Child form.Everything works fine while in the form, but in runtime you can open it and close it immediately and get the unhandled exceptionUnhandled...
30 Sep 2014 by Davester28
Ok, just took a databound combobox that I was using for a search filter, made the following change, and now I don't get the error.Changed from using a table adapter and binding source to grabbing a data table in codePrivate Sub FillVendorSearchCombobox() Try ...
21 Oct 2014 by testkite
Hello,I need a help to add custom property to asp bound field in gridview. can anyone help me to resolve this issue. for more clarity see the below code.
20 Oct 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
I would suggest you to go for TemplateField and inside that add whatever control you want to bind.Otherwise, you can look at the below articles.1. Required BoundField in GridView[^]2. How to create custom bound fields in GridView[^]
30 Oct 2014 by Cá Cơm
I have a class named "Dimensions", like that:using System;using System.ComponentModel;using System.Collections.Generic;using System.Runtime.CompilerServices;using System.Diagnostics;namespace Shopdrawing.Reinforcement{ public class Dimensions : INotifyPropertyChanged ...
4 Nov 2014 by Sander Rossel
Hello all,I'm having a (probably) very common problem. I'd Google, but I'm not sure what to Google for.The problem I have is as follows:I have a class with a few properties, say PropertyA, PropertyB and PropertyC.When I set PropertyA I want PropertyB and PropertyC to get certain values...
6 Nov 2014 by chandra sekhar
I am assigning value to a bool value likepublic bool Isoverhung=false;and i am fetching the value likeclass.Isoverhung=_presenter.Getthevalue();But i am getting null reference exception how can i solve this?
6 Nov 2014 by Mukesh Ghosh
_presenter.Getthevalue(); Must be return undefine Value.Check like convert.tobool(_presenter.Getthevalue())
6 Nov 2014 by DamithSL
class.Isoverhung=_presenter.Ge...
6 Nov 2014 by VC.J
try this ternarry operatorbool outValue;class.Isoverhung=bool.TryParse(_presenter.Getthevalue(),out outValue)?outValue:default(bool);
6 Nov 2014 by Laiju k
class.Isoverhung=_presenter.Ge...
26 Dec 2014 by Dave Kreskowiak
Your properties that you want to set from the designer code need the DesignerSerializationVisibility attribute added to them.For example: [Category("MyProject.Forms"), DefaultValue(0),Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] ...
5 Feb 2015 by ssnk
i am making wpf app which have two page.first page add items in list(ObservableCollection) and second page display this list using listview control .i am using frame in window(wpf) to display page.list correctly work in page1 but when page navigate (page1 to page2) list lost its data and doesn't...
7 Feb 2015 by BillWoodruff
If you want Forms to have access to the value (contents) of a Field/Property (variable) in another Form, then you have two essential choices:1. make the Field/Property in the Form you wish to share 'static: then that Field becomes a Field of the Class, rather than a Field of each instance of...
18 Feb 2015 by Vladimir Svyatski
That's easy. Let's assume your control class name is MyTextBox. Now you do thisMyTextBox txtBox = this.ActiveControl as MyTextBox;if (txtBox != null){ //Bingo, the active control is MyTextBox //Accessing IsValidate property txtBox.IsValidate = false;}Of course, make sure...
7 Mar 2015 by Reatellino
Hi guys need some help please. I've got a ListView. The ListView is bound to one of the properiets which is a collection ex. Item Source={Binding Collection1} . In C# the code I have got this: ListView.DataContext=name of the object. That is working but...The thing is that properties that...
8 Mar 2015 by George Swan
I would suggest using an item view model as a wrapper for the objects that you wish to display. The objects could implement an interface that defines a method to display the data. Then bind a property in the view model to the items display in the view. This property would call the model’s...
13 Mar 2015 by BillWoodruff
Try changing your implementation to this:public event PropertyChangedEventHandler PropertyChanged;protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null){ var handler = PropertyChanged; if (handler != null) handler(this, new...
27 Mar 2015 by AnoopkumarS
How can i set ViewState["Drivers"] to null using jQuery in ASP.NET ?ViewState["Drivers"]= null;
27 Mar 2015 by Afzaal Ahmad Zeeshan
You should know that ViewState (and other MVC's objects) are server-side and are manipulated on the run-time, after the content is sent (in HTML form) to the client, there is no connection to those objects anymore. To manipulate the DOM then, you have to use JavaScript (or jQuery specifically)...
31 Mar 2015 by Member 10794476
I am new to WPF C#, I am trying to create a User Control with custom properties. I have a property with the name Planet.And this property can take values as Mercury, Venus, Earth and Mars.During the design time, when I include this control in my application, and type the property name, I...
31 Mar 2015 by Sergey Alexandrovich Kryukov
As I understand, this is an enumeration-type property, exactly as Alignment (anything else would simply make no sense). Well, you don't need anything special, just write a public property with public type. Only if you need to customize presentation of this property, you have to put a lot more...