What's the simplest way to override a property's default value?

I'm trying to write a TCustomDBGrid descendant that's designed to feel like a TListBox.  One of the things I want to change is the Options property's defaults.  TCustomDBGrid defines Options as:

    property Options: TDBGridOptions read FOptions write SetOptions
      default [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgConfirmDelete, dgCancelOnExit];

Trying to override that in my class with

      property Options: TDBGridOptions default
         [dgTitles, dgTabs, dgRowSelect, dgAlwaysShowSelection, dgCancelOnExit];

doesn't work; the compiler expects *read* or *write* after the type, not *default*.  Problem is, FOptions and SetOptions are both defined as private, not protected, in TCustomDBGrid.

Do I have to write my own get and set methods that invoke "*inherited* Options", or is there a simpler way?
0
Mason
12/3/2008 8:55:47 PM
embarcadero.delphi.oodesign 456 articles. 0 followers. Follow

1 Replies
789 Views

Similar Articles

[PageSpeed] 58

Mason Wheeler wrote:
> I'm trying to write a TCustomDBGrid descendant that's designed to feel like a TListBox.  One of the things I want to change is the Options property's defaults.  TCustomDBGrid defines Options as:
> 
>     property Options: TDBGridOptions read FOptions write SetOptions
>       default [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgConfirmDelete, dgCancelOnExit];
> 
> Trying to override that in my class with
> 
>       property Options: TDBGridOptions default
>          [dgTitles, dgTabs, dgRowSelect, dgAlwaysShowSelection, dgCancelOnExit];

That merely changes the value that the IDE treats as the one it doesn't 
need to bother storing to the DFM when it saves the form and its 
components. It has absolutely no effect at run time, and it does not 
change the value of any property.

> doesn't work; the compiler expects *read* or *write* after the type, not *default*.

Try removing the type.

property Options default ...;

> Problem is, FOptions and SetOptions are both defined as private, not protected, in TCustomDBGrid.
> 
> Do I have to write my own get and set methods that invoke "*inherited* Options", or is there a simpler way?

Since you haven't actually changed what the initial value will be for 
that property, you'll still need to write some code. Do it in the 
constructor:

begin
   inherited;
   Options := NewDefaultOptions;
end;

Any forms that were using the old set of default options will get the 
new set the next time the form is loaded (at design time or run time). 
This is because the Options property was never saved for that form 
anyway, due to the "default" directive on the original property declaration.

-- 
Rob
0
Rob
12/3/2008 9:10:44 PM
Reply:

Similar Artilces:

Help! I cannot access the DataGrid's ItemTemplate's LinkButton's Text Atrribute 's Value!!!!!!!!!!!
I write a datagrid's ItemDataBound method as follows:   private void dgTable_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)  {   if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)   {    if(!isRole("Manager"))    {     LinkButton tmp = (LinkButton)e.Item.FindControl("lbPassed");     if(tmp.Text == "Passed")     {      ((LinkBu...

Default value for Dropdownlist that get's it's value from Database.
Hi, I am using an Object Data Souce to retrieve the value of a Dropdownlist from a table on MS SQL server 2005. I want to make a default value appear on the Dropdownlist intially, should i enter the default value into the database table or is that a better way of doing it? Any suggestions will be very much appreciated. E  No need for database just set sekected value after databingind protected void Page_Load(object sender, EventArgs e) { DataBind(); ListItem defaultItem = new ListItem("Select a Person", "-1"); th...

The value's length for key 'data source' exceeds it's limit of '128'.
Hii, When I tried to bind dropdownlist to database by declaring connection string in the code behind file I am getting this error: The value's length for key 'data source' exceeds it's limit of '128'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: The value's length for key 'data source' exceeds it's limit of '128'.Source Error: An...

Control's (object's) default value??
How or where can I see an asp.net control's default value? Say, for example the Visible property for webcontrols? Would be preferable if I could quickly see it in Visual Web Developer but MSDN online documentation would also be nice. Also how can I do this in general for all .Net objects?...

Replace 1's and 0's in a gridview column with Yes's and No's
Is it possible to change the display of a column in a gridview to show a Yes for all 1's and a No for 0's that display in a particular column of a gridview bound to a database?  If so, can someone share the way with me?  I am using ASP.NET 2.0 with VB Code Behind.  Thanks One way you can do is thrrough  CASE in your select statement: Select YesNoColumn= CASE yourColumn WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' ELSE '' END FROM YourtableLimno <Columns>     <asp:TemplateField HeaderText="yourHeader" SortExpression="yourDataField"> ...

Meke Control's property disabled or enabled based on another property's entered value ?
Does anyone know how to disable or enable a property in properties window based on value entered in another property?Please advise.Regards,Dimitry...

It's Linux !? No, it's BSD ! No, no, it's...
kFreeBSD http://wiki.debian.org/Debian_GNU/kFreeBSD a Debian distro using the FreeBSD kernel ! ObiWan wrote: > kFreeBSD > > http://wiki.debian.org/Debian_GNU/kFreeBSD > > a Debian distro using the FreeBSD kernel ! Why use a BSD kernel? I hope the reason is more than, just because they can. http://wiki.debian.org/Debian_GNU/kFreeBSD_why It's easy to understand why the would want to use Debian packages. :) -- Jimmy Johnson Registered Linux User #380263 >> kFreeBSD >> >> http://wiki.debian.org/Debian_GNU/kFreeBSD >> ...

Hyperlink's, ImageURL's, and OnError's
I created an ASP:Hyperlink and set the ImageURL attribute so the link will be the image.If the image is missing, I would like it to display a 'missing image' pic that I have.  I know you can use the OnError attribute of the <img> tag to run some javascript to change it.Unfortunately I can't find a way to access the Hyperlink's Image that is inside it, so I can add an Attribute so the resulting <img> tag will have an OnError attribute inside of it.Any help?If my Hyperlink is called 'foo'....would I do...  ((Image) foo.Controls[0]).Attributes.Add(&...

Who's Intellectual Property Ours or Their's!*
Which type are these *!%^* worried about! http://www.telecomseurope.net/content/secret-copyright-treaty-takes-aim-isps http://www.newscientist.com/blogs/shortsharpscience/2010/02/online-copyright-clampdown-con.html?DCMP=OTC-rss&nsref=online-news http://www.pcworld.com/article/189922/ "Futuristic" <key562.invalid@aol.invalid> wrote in message news:hm10dk$nt1$1@news.grc.com... > Which type are these *!%^* worried about! > > http://www.telecomseurope.net/content/secret-copyright-treaty-takes-aim-isps > http://www.newscientist.com/blogs/shortshar...

Who's show is SN? Steve's or Leo's?
I don't want to start anything (honestly)! Just want to ask a simple question. Does the Security Now podcast belong to Steve Gibson or Leo Laporte? Maybe I'm in a world all to myself, but when I listen to the excellent SN podcasts, I want to hear STEVE, not Leo. But especially in the past few shows, it seems Leo will repeatedly interrupt Steve in the middle of a sentence that I want to hear the rest of. I consider this very rude of Leo. Steve is making a point that I (we) want to hear, then looses his train of thought after Leo barges in and asks something. It...

DataSet's DataTable's and TableAdapter's Oh My!
Here is my situation.  I am using VB as my programming language.I am creating a part of a website that will be the admin section.  I want the admin to be able to add/edit data in a set of tables that normal users can't.  There are 20 lookup tables that I use in the website that I want the admin to be able to manage (i.e. add, edit, delete, insert).  I don't want to create 20 separate web pages (one for each table).  I have one page that has links to all the tables.  Each link has a "table" querystring variable associated with it.  When the...

Guru's..?? Any do's and/or dont's for Zfd4 and Citrix..?
We've got a nw6/sp5 network with GW 6.5, bm3.7 and zfd 4.01 up'n'running.. Now we're adding a citrix server ( win2003) to the mix, will supply a couple off app's to users over the internal VPN in another city. Probably we'll skip the AD phase since we can not see any app and/or user with the need for AD. So,, any special considorations..? tip's'tricks..? known issues...? t.i.a... On Mon, 16 Aug 2004 15:57:10 GMT, Emerson wrote: > So,, any special considorations..? tip's'tricks..? known issues...? biggest one... zfd4.x d...

Create a DIV's property that points other's object property...
Hi, I have a DIV object. I want to create a property type pointer, that points to a other's object property. For example: I want add a property SelectedIndex to a DIV object. This property must points to the property SelectedIndex of another combo object. In other words. I want that if the combo's property change its value, the property in the DIV object must be changed too. I want the same in the reverse direction. I don't want to use the onchange of the combo objet. I want that if we interact with the combo's property in script, the changes should be reflected in the DIV's...

411 it's pconsole, 51 it's NWPMW32, 65 it's ???
I like to give some of my users controll over their print jobs. In Netware 3.x to 4.x it was pconsole. In Netware 5.x it was NWPMW32. I don't seem to be able to find the same type of utility for Netware 6.5? We don't like to give user access to nwadmin and the NWPMW32 I copied from my 51 server (TID 10075273) to the 65 server won't display the jobs. Mmccabe, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If not, you might try o...

Web resources about - What's the simplest way to override a property's default value? - embarcadero.delphi.oodesign

Resources last updated: 11/28/2015 7:16:03 PM