473,548 Members | 2,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UserControl Property Grid

I have created the following usercontrol

public class RegisterUser : TemplatedWebCon trol {
private VisFields _vfields = new VisFields();
public VisFields VisibleFields {
get { return _vfields; }
set { _vfields = value; }
}

private bool _showit;
public bool ShowIt {
get { return _showit; }
set { _showit=value;}
}

public RegisterUser() : base() {
}
VisFields is a custom class that has properties of boolean
[TypeConverter(t ypeof(VisFields Converter)), Description("Se lect Visible
Fields")]
public class VisFields {
private bool _firstQuestion;
private bool _secondQuestion ;

[DefaultValue(tr ue)]
public bool FirstQuestion {
get { return _firstQuestion; }
set { _firstQuestion = value; }
}

[DefaultValue(tr ue)]
public bool SecondQuestion {
get { return _secondQuestion ; }
set { _secondQuestion = value; }
}

}

if have of also implemented VisFieldConvert er
public class VisFieldsConver ter : ExpandableObjec tConverter {
..
..
..
}

When i drag and drop the control into my webpage, and click on the
property grid, i see the (VisibleFields) property and i can expand it
and see its properties (FirstQuestion, SecondQuestion) . I can change
them to true/false, but when i switch to source of design mode, or even
when i run the page, these properties always have their default value.
So the problem is that the control CAN'T keep the changes i make from
design mode. Any ideas??

Jan 18 '07 #1
1 1706
If you want to keep the values in the properties, you should use ViewState
for that.

public bool SecondQuestion {
get {
if(ViewState["SecondQuestion "] != null)
return
Convert.ToBoole an(ViewState["SecondQuestion "]);
return true;
}
set { ViewState["SecondQuestion "] = value; }
}
It works fine. :)
<ma******@gmail .comwrote in message
news:11******** **************@ a75g2000cwd.goo glegroups.com.. .
>I have created the following usercontrol

public class RegisterUser : TemplatedWebCon trol {
private VisFields _vfields = new VisFields();
public VisFields VisibleFields {
get { return _vfields; }
set { _vfields = value; }
}

private bool _showit;
public bool ShowIt {
get { return _showit; }
set { _showit=value;}
}

public RegisterUser() : base() {
}
VisFields is a custom class that has properties of boolean
[TypeConverter(t ypeof(VisFields Converter)), Description("Se lect Visible
Fields")]
public class VisFields {
private bool _firstQuestion;
private bool _secondQuestion ;

[DefaultValue(tr ue)]
public bool FirstQuestion {
get { return _firstQuestion; }
set { _firstQuestion = value; }
}

[DefaultValue(tr ue)]
public bool SecondQuestion {
get { return _secondQuestion ; }
set { _secondQuestion = value; }
}

}

if have of also implemented VisFieldConvert er
public class VisFieldsConver ter : ExpandableObjec tConverter {
.
.
.
}

When i drag and drop the control into my webpage, and click on the
property grid, i see the (VisibleFields) property and i can expand it
and see its properties (FirstQuestion, SecondQuestion) . I can change
them to true/false, but when i switch to source of design mode, or even
when i run the page, these properties always have their default value.
So the problem is that the control CAN'T keep the changes i make from
design mode. Any ideas??

Jan 18 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2456
by: Steve | last post by:
Hi, I have a UserControl which I would like the user to be able to configure through the property grid at runtime. How can I hide certain properties that you get as standard such as Anchor and Autoscroll. Or is it possible to hide whole Category sections, and only show my own custom properties at runtime? Thanks in advance. Steve.
0
1978
by: Colin Ramsay | last post by:
Hi all, I don't normally post swathes of code like this but I am truly banging my head off my desk here... I've dynamically created a datagrid within a usercontrol. There are two columns which contain buttons to Edit & Delete rows. For some reason, the ItemCommand event which these should be connected to isn't firing.
6
1972
by: Anonymous | last post by:
Hello, I am loading a usercontrol with the LoadControl method and need to pass some data to the property of that control. How can I do that? THanks
6
1921
by: Pete Davis | last post by:
I'm fairly weak with ASP.NET. What I'm trying to do is pass an attribute to a UserControl. The attribute is a value from the CodeBehind for the page. So in my .aspx I have the following: <cm:Comments runat="server" ID="Comments1" CommentType="News" ItemID="<%= NewsItemID %>" /> NewsItemID is a property in the CodeBehind for the page.
0
839
by: elziko | last post by:
I have a UserControl inside my project. When I click on the UserControl in the design view I get to also view all its properties in the property grid. I the change the AllowDrop property to True. However, when I then use this compiled UserControl in any other project AllowDrop defaults back to False. I assume this is by design but why?...
7
2506
by: steve.kaye | last post by:
I am writing a number of controls which use inheritance and I have a problem that I do not know how to solve. It's best if I describe the class structure I want. Grid - derives from UserControl and contains most of the functionality required of a basic grid. ViewGrid, EditGrid and TreeGrid - all derive from Grid The problem I have is...
0
2529
by: osmarjunior | last post by:
Hi. I have a UserControl with a DataGridView and 3 buttons (New, Edit and Delete) inside. I wanna do something like that: when the focus leaves the UserControl, it hides the selection of the grid. So, in the Leave event of the UserControl i made the following: myGrid.ClearSelection();
2
2815
by: Mark Collard | last post by:
The ToolBar control allows you to add toolbar buttons. When you add a button, the button is not only displayed in the toolbar, but also added as a separator control in the form/usercontrol your toolbar exists in. I'm writing my own usercontrol which contains various different controls (e.g. Panel, Button). I would like these controls to be...
6
12123
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use binding like normal. The problem I am running into is that my UserControl ends up with a different BindingContext then the ParentForm it is...
0
7518
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7444
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...
0
7711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7954
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7467
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...
1
5367
isladogs
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...
0
5085
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...
0
3497
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...
1
1054
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.