Hide BindableList Properties
Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1263
Printed Date: 23-Apr-2025 at 9:08pm
Topic: Hide BindableList Properties
Posted By: kjohnson
Subject: Hide BindableList Properties
Date Posted: 15-May-2009 at 12:42pm
I'm currently build an application using both DevForce classic and
DevExpress tools. I'm including the DevExpress End-User Report
Designer so users can create custom reports. I've managed to get it
working by using the IdeaBlade BindableList<> as the datasource.
The main problem I've encountered is in which fields are available to
the user.
For instance I use a BindableList<Orders> as
the datasource. One of the fields in the Orders table is OrderDate,
when the report designer looks for fields it finds the OrderDate
property and OrderDateColumn which only displays on a report as
[Model.Orders]. Basically, I want to keep these *Column properties
from being shown. I have been searching through the knowledge bases
and forums for both IdeaBlade and DevExpress, and found several
possible leads to make this happen, but none have worked so far. Can
someone point me in the right direction in how to hide certain
properties.
|
Replies:
Posted By: GregD
Date Posted: 15-May-2009 at 5:06pm
If I understand you correctly, I think you're asking for properties such as OrderDateColumn to be suppressed in the display presented by the DevExpress End-User Report Designer. Unfortunately we have no control over that. We do add BindingBrowsable attributes into the definition of properties that we generate (such as the following one for the OrderDatecolumn property an Order entity based on the Order table in our IdeaBladeTutorial database):
[EditorBrowsable(EditorBrowsableState.Advanced)] [BindingBrowsable(false)] public virtual DataColumn OrderDateColumn { get { return TypedTable.OrderDateColumn; } }
Our ControlBindingManager designer (along with other DevForce components) respects this attribute and suppresses the display of properties that have it set to false, as you can see if you use the ControlBindingManager in laying out a WinForm. But, as I say, we have no control over what the DevExpress report designer does.
If there is an attribute which that report designer respects (you will have to find this out from DevExpress), then you could override (in your Order developer class) the properties you don't want to display, adding the attribute there. For example, here is an override of the OrderDate property that I've put in my Order class:
[BindingBrowsable(false)] public override DateTime? OrderDate { get { return base.OrderDate; } set { base.OrderDate = value; } }
This causes OrderDate not to display in the ControlBindingManager designer, when ordinarily it would.*
-------------------------------------- * After you add such an attribute you will need to build your model, and at the very least close and re-open the form where you want to use the ControlBindingManager designer to get the change to kick in (past the caching done by Visual Studio). I actually closed and reopened Visual Studio to get the change to take.
|
Posted By: kjohnson
Date Posted: 18-May-2009 at 9:15am
The reason that I'm using the BindableList<> for the DevExpress report datasource is because it preserves the entity relations. I can transfer the needed data by doing:
DataSet dataSet1 = mPersMgr.DataSet;
Unfortunately, when doing this the entity relations (such as the one that would connect Orders with OrderDetails) does not carry over into the dataset. Is there a way to carry these relations into the dataset?
Alternatively, I can simply change the display name of the properties (using the system.componentmodel.displaynameattribute). Is there a way I can write a small function to take any property that ends with "Column" and append "InternalOnly_" onto the front of its display name? Or would I need to override each property?
|
|