473,396 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Default a unique value to property on a component

I have a lot of existing forms that descend from a custom base class.

I want to add to the base class a new property containing a unique string.
When the application is next built i want to default these properties and
then store them for future builds.

This is basically the same as the 'Text' property on a form. When it is
first created it defaults to something like 'Form1' or 'Form2' etc and this
value is stored in the form InitializeComponent method for next time but can
be overriden if required.

If i create a property then edit it at design time it is saved in the
InitializeComponent method. I want to do this automatically.

How do i force a call to rewrite the InitializeComponent method or mark my
property on the component to do this for me.

In the below example if you create a form descendant from the class the
IDString is regenerated everytime until you manually change it at design
time.

public class IDForm : System.Windows.Forms.Form
{
private string m_IDString;
public string IDString
{
get
{
if(m_IDString == null)
IDString = Guid.NewGuid().ToString();
return m_IDString;
}
set
{
m_IDString = value;
}
}
}

thanks in advance
Nov 17 '05 #1
0 981

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

Similar topics

2
by: CMan | last post by:
Hi All, I am trying to use a COM component that has methods with default parameters. How can I call these methods from C#. Not all default values are in the documentation of the control. ...
1
by: cching | last post by:
Hi, I'm trying to turn this: <Component> <Properties> <Property Name="X" Value="200" /> <Property Name="Y" Value="200" /> <Property Name="Width" Value="100" /> <Property Name="Height"...
5
by: Ed Havelaar | last post by:
I have a cool function that I want to use as a default value for a column in my table. But I can't because apparently Access doesn't allow user defined functions in expressions for default values....
0
by: Chad Myers | last post by:
*** I posted this in the interop newsgroup, but I'm not sure if it'd get answered there. I didn't want to cross post and possible bug everyone, so sorry if I made a faux-paus. *** I'm writing...
4
by: Olaf Baeyens | last post by:
I am trying to create a control, using standard user components A. The I use that component A as part of a new component B. And finally I drop that component B on my form. Now in Component A I...
0
by: MBO | last post by:
Hello NG, I've created a custom component inherited from "System.Web.UI.Webcontrold.Button" and added a new String Property .... Private _waitMessage As String <Bindable(True),...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
3
by: binder | last post by:
I am designing a new table with a few columns that may or may not have a value on each row that is inserted. What issues determine whether to allow a NULL value to be inserted for that column or...
3
by: mnishani | last post by:
Is there any way to add a default value to a datagrid column(for the whole column - eg : system date) . I'm using vs2003 and datagrid and using dataadapter to update the grid. Thanks in advance
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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...
0
tracyyun
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...

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.