Author |
Share Topic Topic Search Topic Options
|
cblevins
Newbie
Joined: 02-Jun-2009
Posts: 2
|
Post Options
Quote Reply
Topic: How to display multiple columns in a LookupEdit Posted: 21-Jan-2010 at 11:48am |
I've had success using GetPropertyDescriptors to access nested properties in LookUpEdit controls.
// ProductLookupEdit this.ProductLookupEdit.Properties.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] { new LookUpColumnInfo("DefaultSort", "DefaultSort", 74, ColumnSortOrder.Ascending), new LookUpColumnInfo(bsProducts.GetPropertyDescriptor("ProductType.ProductTypeName").Name, "ProductType", 67), new LookUpColumnInfo("ProductName", "Product Name", 70), new LookUpColumnInfo(bsProducts.GetPropertyDescriptor("Event.EventName").Name, "Related Event", 34) }); this.ProductLookupEdit.Properties.DataSource = this.bsProducts; this.ProductLookupEdit.Properties.DisplayMember = "ProductName"; this.ProductLookupEdit.Properties.NullText = "[Choose a Product]"; this.ProductLookupEdit.Properties.ValueMember = "ProductGUID";
Hope this helps,
Chris
|
 |
toddb
Newbie
Joined: 04-Feb-2009
Location: Australia
Posts: 8
|
Post Options
Quote Reply
Posted: 02-Aug-2009 at 4:14pm |
Hi Heather / puctx,
Thankyou both for your replies and suggestions. I had a sinking feeling I was going to have to touch each object in 'some' way. Based on my initial tests, the nested properties seem to work 'ok' with a number of standard .NET controls so I have sent a few emails back and forth to the DevExpress team suggesting that the whole nested property issue could be supported a little better. I'll post back here if I get a 'positive' response. In the mean time "quick-n-dirty" it will have to be :)
Kind regards,
Todd.
|
 |
HFloyd
Groupie
Joined: 27-Jul-2007
Location: United States
Posts: 44
|
Post Options
Quote Reply
Posted: 31-Jul-2009 at 8:47am |
Hi Todd, No, I never got it working with extended properties. What I ended up doing was adding additional "calculated" properties to my business objects that I could reference directly. For instance, For the Product object, with a relation to an Event object, which I wanted to display via Event.EventName, I added a new property to the Product object (something like this pseudo-code):
Product class:
string RelatedEventName { return this.Event.EventName }
|
This is annoying because it clutters the objects a bit, and you have to do it for whatever "labels" you want to use, but it did work. It is a "quick-n-dirty" solution. Perhaps it will help you. Good luck, Heather
|
 |
pucsoftware
Groupie
Joined: 15-Apr-2008
Location: United States
Posts: 46
|
Post Options
Quote Reply
Posted: 31-Jul-2009 at 6:31am |
I don't use the DevForce BindingManagers at all anymore. For the most part they worked, except when dealing with complex components from DevExpress like multi column lookups. One thing I discovered while using the BindingManagers though was that it created a "_self" property for the list object that returns an intance of the object type for that record, to be used as a value for the field rather than a simple value. Also, there is a property for fields that have lookup relations to other tables is usually created by DevForce that are named similar to "Employee_fk_Department" for example. This value is the field in the parent table that stores the key value that is used to reference the appropriate record in the lookup table. The issue I have with this property is that you can not rename the property.
So, in order to get around this I made adjustments to all my partial classes of my Objects that create a _Self property and added nicer property name wrappers for the foriegn key values in the main table. Just be careful that if you rename the Navigation and Associations properties in the DevForce designer that you don't create dup names. Come up with a strategy where, once you get in the visual designers, you know which field you are referencing.
For Example, in my partial class
// for Employees:
/// <summary>Get DepartmentKey from Employee</summary> public string EP_DepartmentKey { get { return this.Department_fk_DepartmentKey; } set { this.Department_fk_DepartmentKey = value; } }
// for Department:
/// <summary>Get Department object</summary> public Department _Self { get { return this; } }
One note. These two properties don't work in conjunction, they both solve two different issues for binding DevForce objects without using the BindingManagers and only using .NET Binding.
If you want to use the DepartmentKey method, then you would bind a lookup using the key value from the lookup table.
Otherwise:
Main Table Bind Field: DepartmentKey from Employee Table
Lkup Table Bind Field: DepartmentKey from Department Table
Lkup Table Display Field: DepartmentName from Department Table
If you want to use the _Self method, then you would bind the lookup using the _Self value that represents the object.
Main Table Bind Field: Department from Employee Table
Lkup Table Bind Field: _Self from Department Table
Lkup Table Display Field: DepartmentName from Department Table
Not sure how this works with XtraReports but it works with WinForms controls, XtraGrids, and LookUp Edits, or any other grid Editor i've tried. Hope this helps.
|
puctx
|
 |
toddb
Newbie
Joined: 04-Feb-2009
Location: Australia
Posts: 8
|
Post Options
Quote Reply
Posted: 30-Jul-2009 at 5:14pm |
Hi Heather,
You posted quite a few months back about a problem you were having with nested properties and getting them to display in the LookUpEdit control.
Originally posted by HFloyd
Hi, I was wondering about how to access a nested property to display in a LookupEdit column? If I set the fieldname using the dot notation (aka: "ProductType.ProductTypeName", "Event.EventName")(which works in XtraReports, for instance), I just get a blank value in the column.
Here is my example:
// ProductLookupEdit this.ProductLookupEdit.Properties.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] { new LookUpColumnInfo("DefaultSort", "DefaultSort", 74, ColumnSortOrder.Ascending), new LookUpColumnInfo("ProductType.ProductTypeName", "Product Type", 67), new LookUpColumnInfo("ProductName", "Product Name", 70), new LookUpColumnInfo("Event.EventName", "Related Event", 34) }); this.ProductLookupEdit.Properties.DataSource = this.bsProducts; this.ProductLookupEdit.Properties.DisplayMember = "ProductName"; this.ProductLookupEdit.Properties.NullText = "[Choose a Product]"; this.ProductLookupEdit.Properties.ValueMember = "ProductGUID";
|
Is there some way I can get the nested properties to show up?
Thanks!
Heather
|
I am having the same problem - if you, or anyone else for that matter :), managed to get it working they way you wanted, could you please share with me how exactly how?
Kind regards,
Todd
|
 |
pucsoftware
Groupie
Joined: 15-Apr-2008
Location: United States
Posts: 46
|
Post Options
Quote Reply
Posted: 06-Nov-2008 at 2:09pm |
The way I worked around this is to not bind the field that I wanted with the DevForce binding manager. I ended up using a regular DevExpress GridLookup control, set my multiple columns the way I wanted then bound the edit value to the actual binding source control on the form and set the correct field I wanted. This seemed to work fine and saved and updated correctly. I think I also found that if you perform any edit (even in code) to the binding source object the Devforce managers seem to recognize the edit, too. I don't know what is really going on behind the scene and if there are any gotchas to be wary of but it did seem to work Hope this helps... Now if only I get my DevForce EF version working..
|
puctx
|
 |
HFloyd
Groupie
Joined: 27-Jul-2007
Location: United States
Posts: 44
|
Post Options
Quote Reply
Posted: 06-Nov-2008 at 1:55pm |
Thanks for the idea, JeeZ, but it doesn't seem to work. The column is still blank.
|
 |
JeeZ
Newbie
Joined: 14-Nov-2007
Location: Canada
Posts: 10
|
Post Options
Quote Reply
Posted: 05-Oct-2008 at 9:28pm |
Try using the underscore notation instead :
... becomes ...
... which is the PropertyPath value.
// ProductLookupEdit
this.ProductLookupEdit.Properties.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] { new LookUpColumnInfo("DefaultSort", "DefaultSort", 74, ColumnSortOrder.Ascending), new LookUpColumnInfo("__ProductType_ProductTypeName", "Product Type", 67), new LookUpColumnInfo("ProductName", "Product Name", 70), new LookUpColumnInfo("__Event_EventName", "Related Event", 34) }); this.ProductLookupEdit.Properties.DataSource = this.bsProducts; this.ProductLookupEdit.Properties.DisplayMember = "ProductName"; this.ProductLookupEdit.Properties.NullText = "[Choose a Product]"; this.ProductLookupEdit.Properties.ValueMember = "ProductGUID";
|
Edited by JeeZ - 05-Oct-2008 at 9:29pm
|
 |
HFloyd
Groupie
Joined: 27-Jul-2007
Location: United States
Posts: 44
|
Post Options
Quote Reply
Posted: 04-Oct-2008 at 2:10pm |
Hi, I was wondering about how to access a nested property to display in a LookupEdit column? If I set the fieldname using the dot notation (aka: "ProductType.ProductTypeName", "Event.EventName")(which works in XtraReports, for instance), I just get a blank value in the column. Here is my example:
// ProductLookupEdit this.ProductLookupEdit.Properties.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] { new LookUpColumnInfo("DefaultSort", "DefaultSort", 74, ColumnSortOrder.Ascending), new LookUpColumnInfo("ProductType.ProductTypeName", "Product Type", 67), new LookUpColumnInfo("ProductName", "Product Name", 70), new LookUpColumnInfo("Event.EventName", "Related Event", 34) }); this.ProductLookupEdit.Properties.DataSource = this.bsProducts; this.ProductLookupEdit.Properties.DisplayMember = "ProductName"; this.ProductLookupEdit.Properties.NullText = "[Choose a Product]"; this.ProductLookupEdit.Properties.ValueMember = "ProductGUID";
|
Is there some way I can get the nested properties to show up? Thanks! Heather
|
 |
davidklitzke
IdeaBlade
Joined: 14-Jun-2007
Posts: 715
|
Post Options
Quote Reply
Posted: 25-May-2008 at 9:44am |
Darren,
One of the Tools for DExperience 8.1 is called "Project Converter". It will allow you to convert projects built with older versions of DevEX to the 8.1 version.
David
|
 |
pucsoftware
Groupie
Joined: 15-Apr-2008
Location: United States
Posts: 46
|
Post Options
Quote Reply
Posted: 22-May-2008 at 2:14pm |
I need to know how to display multiple columns for a field in a DevExpress lookupEdit. This example is older and won't work with the latest VS.NET and the DevExpress 8.1 components installed. Or if you have instructions on how to do this that would be good enough. Also, do you know if the GridLookupEdit is supported now? Thanks for your help.
Darren
|
 |
davidklitzke
IdeaBlade
Joined: 14-Jun-2007
Posts: 715
|
Post Options
Quote Reply
Posted: 14-Nov-2007 at 3:30pm |
The GridLookUpEdit is not a DevEx control that we currently support. We would need to write a DataBinder for it. There is an existing Feature Enhancement Request for this functionality.
|
 |
JeeZ
Newbie
Joined: 14-Nov-2007
Location: Canada
Posts: 10
|
Post Options
Quote Reply
Posted: 14-Nov-2007 at 2:15pm |
Hi,
Do you have a VB code sample for the GridLookupEdit ? I'm able to use the LookupEdit, but I had no luck with the GridLookupEdit. Thanks!
|
 |
IdeaBlade
Moderator Group
Joined: 30-May-2007
Location: United States
Posts: 353
|
Post Options
Quote Reply
Posted: 16-Jul-2007 at 10:35am |
I’ve attached a code sample for multiple columns in a LookUpEdit.
Edited by IdeaBlade - 16-Jul-2007 at 1:16pm
|
 |
Customer
Senior Member
User Submitted Questions to Support
Joined: 30-May-2007
Location: United States
Posts: 260
|
Post Options
Quote Reply
Posted: 16-Jul-2007 at 10:32am |
When attempting to use the GridLookupEdit / LookupEdit controls from DevExpress, one of the most desireable properties is the ability to display multiple columns in the Popup list of the controls(with their flavours). Is this functionality supported by the xtraGridBindingManager / ControlBindingManager ?
Edited by IdeaBlade - 16-Jul-2007 at 10:34am
|
 |