Hi all,
I have one class including one collection. I use propertygrid to display and
edit its properties.
I'm trying to use reflection to change the status of one element to be
readonly, for example the first element in this collection.The result is
that all of elements changed. I guess the ReadOnly attribute is for class(or
type), not for instance.
How could i only change the status of one element of one collection?
Thanks in advance.
Alan 2 2914
I don't think that is a good idea.
You should manage the state of the elements at your get/set modifiers.
Like - throwing a custom exception when it's the first element in the
collection.
Cheers,
Branimir
--
Branimir Giurov
MCSD.NET, MCDBA
"Alan" <li***@channel. com> wrote in message
news:e3******** ******@TK2MSFTN GP09.phx.gbl... Hi all, I have one class including one collection. I use propertygrid to display and edit its properties. I'm trying to use reflection to change the status of one element to be readonly, for example the first element in this collection.The result is that all of elements changed. I guess the ReadOnly attribute is for class(or type), not for instance. How could i only change the status of one element of one collection?
Thanks in advance.
Alan
>I have one class including one collection. I use propertygrid to display and edit its properties. I'm trying to use reflection to change the status of one element to be readonly, for example the first element in this collection.The result is that all of elements changed. I guess the ReadOnly attribute is for class(or type), not for instance. How could i only change the status of one element of one collection?
In that case, you'd have to have a private boolean flag in the class,
which would indicate whether or not your special property is
read-only, or not.
In the Set accessor for that property, you'd need to check for that
flag, and if it's true, you'd simply discard / disregard the value
being set.
I don't think there's another way to do this, since as you say, the
property's status is otherwise a function of the CLASS, not the
instance....
Marc
=============== =============== =============== =============== ====
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)i nova.ch This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: svilen |
last post by:
hello again.
i'm now into using python instead of another language(s) for
describing structures of data, including names, structure,
type-checks, conversions, value-validations, metadata etc. And i have
things to offer, and to request.
And a lot of ideas, but who needs them....
here's an example (from type_struct.py):
|
by: bruno modulix |
last post by:
Hi
How can I make a *class* attribute read-only ?
The answer must be pretty obvious but I just can't find it (it's late
and I've spent all day on metaclasses, descriptors and the like, which,
as fun as it is, may have side-effects on intellectual abilities...)
*The context:*
|
by: Matt |
last post by:
I want to know if readOnly attribute doesn't work for drop down list?
If I try disabled attribute, it works fine for drop down list. When I
try text box, it works fine for both disabled and readOnly attribute.
For example, #1 will work, but #2 doesn't work
1) <SELECT name="streetDirection" class="FormInput" DISABLED>
In JavaScript, I have InputForm.streetDirection.disabled = false;
2) <SELECT name="streetDirection" class="FormInput"...
|
by: GP |
last post by:
Is it possible to iterate through all the controls collection and make the
textboxes alone as read only.I don't see a readonly property for the
Control.Can some one help me in this context?
I want to do something like this below.But I get a message Readonly is not
valid property.
foreach (Control ctl in pnlBenefits.Controls)
{
if (ctl is TextBox)
ctl.ReadOnly=false;
}
|
by: Brian Young |
last post by:
Hi all.
I'm using the Property Grid control in a control to manage a windows service
we have developed here. The windows service runs a set of other jobs that
need to be managed. The control is used to view the state of the running
jobs and schedule new jobs. The control also runs in the context of
Internet Explorer (we do this so the administrators of the jobs can always
receive the latest control). The property grid is used to...
| |
by: fred |
last post by:
With a Class is there any difference between a readonly property and
function besides having to use Get/End Get.
Are there any performance/resource advantages for either.
Thanks
Fred
|
by: Tom |
last post by:
I'm using the PropertyGrid, and have it bound to a class object. Works
fine - however, I have some properties that I want to show up on the grid
(i.e. they are browsable) -YET- I don't want the user to be able to change
them; i.e. want them ReadOnly to the grid. I tried setting that classes
property to the ReadOnly attrib, but it wouldn't take it. (Keywork is not
valid as an identifier)
So how can one have a property value that shows up...
|
by: Raja |
last post by:
Hi Everybody
Just playing with ObjectDataSource and noticed the following.
I have a Gridview which binds to a ObjectDataSource. ObjectDataSource
gets data from a typed dataset created with VWD. In the table from
which the data is coming has a Primary Key field.
Gridview is set to edit mode. DataKeyNames = "PK_Field". Now if PK
field is not readonly, then data is updated successfully. But if I set
PK Field to readonly, then data is not...
|
by: Hamed |
last post by:
Hello
I have a DataGrid object in my ASP.NET page that has the following template
column. When I put the "readonly" attribute in the INPUT tag, it generates
readonly="".
<asp:TemplateColumn HeaderText="Kg Price" HeaderStyle-Width="5%">
<ItemTemplate><INPUT class="ep" id=kf readOnly value='<%#
DataBinder.Eval(Container, "DataItem.KgFee") %>' name=kf
runat="server"></ItemTemplate>
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |