Print Page | Close Window

[CANCELLED] ListConverter in an Unbound User Control

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=604
Printed Date: 10-Jun-2026 at 10:14pm


Topic: [CANCELLED] ListConverter in an Unbound User Control
Posted By: Linguinut
Subject: [CANCELLED] ListConverter in an Unbound User Control
Date Posted: 11-Dec-2007 at 2:45pm

I have a user control that is not bound to any business object.  I would like the form to display a set of DevExpress LookUpEdit controls (among other things).  Since the ControlBindingManager is not being used, how would I point an existing ListConverter (from the ListConverterService) to a LookUpEdit control?  In other words, how do I wire a ListConverter to a control without going through a ControlBindingManager?

Thanks,
Bill



Replies:
Posted By: Linguinut
Date Posted: 11-Dec-2007 at 3:37pm
Here is what I did:
 
1.  Add public bindingsource to the presenter:
 
public BindingSource mMachineBS = new BindingSource();
 
2.  After the OnViewSet call, I set the datasource of the BindingSource to the List of the ListConverter, like this:

mMachineBS.DataSource = (ListConverterService.Get(ListConverterNames.MachineList, true)).List;

3.  From the view, I point the control's data source to the BindingSource:
 
mMachineNumberLookUpEdit.Properties.DataSource = Presenter.mMachineBS;
 
Now, all of this works...I can even filter and sort within the presenter.  I am just having trouble with the display value.  It is like the entire business object schema is being shown.  If I figure it out, I'll let you know.


Posted By: mykel
Date Posted: 11-Dec-2007 at 11:27pm
Hello,
 
I'm having the same problem with the listconverter and the LookupEdit of DevXpress but in my case, I want to populate a gridview column. When I look at the list of the LookupEdit, all I can see is blank list of records. I think the records are right, it just not shows the real value even if I set the DisplayMember and ValueMember of the Listconverter.
 
 


Posted By: Linguinut
Date Posted: 12-Dec-2007 at 1:50pm
Hi mykel,
 
I have a few grids in which I need to work on that same problem.  My main one that I will need to address is a sales order details grid.  I have a units column that I want represented by a drop down list.  It is also empty at the moment.  As soon as I get back to that one, I will let you know what I did to figure it out.  Sorry that I cannot provide any kind of answer right now...maybe IdeaBlade could pop in here and add something.
 
Bill


Posted By: mykel
Date Posted: 12-Dec-2007 at 6:34pm
Hello,
 
I am able to make my lookupedit work. I just used the AdaptiveList.Adapter method of Devforce to make sure that I am setting a consistent Object Type in the ListConverter. The initial data source Type of the listconverter or the dropdown list should consistently be the same with what you are setting up during run time. Try also to add the setting of the DisplayMember and ValueMember right before the Setting of the data source. I think this fixes the displaying of the value once u select a record from the list. :)
 
Hope this helps. :)


Posted By: mykel
Date Posted: 12-Dec-2007 at 6:35pm
Something like this:
 
lookEdit.Properties.DisplayMember = EntityPropertyDescriptors.GSCSecurityTemplateFields.FieldName.Name;

lookEdit.Properties.ValueMember = EntityPropertyDescriptors.GSCSecurityTemplateFields.FieldName.Name;

lookEdit.Properties.DataSource = IdeaBlade.Util.AdaptiveList.Adapter(listfields, true);



Posted By: Linguinut
Date Posted: 12-Dec-2007 at 6:46pm
I have never heard of the AdaptiveList.Adapter method.  Shocked  What is an AdaptiveList?  Also, what is your "listfields" parameter referencing?


Posted By: mykel
Date Posted: 12-Dec-2007 at 6:57pm

Initially I set the listconverter i am tying up with my lookedit with a System.Collections.List<string> object, since the list of records I have is not from a specific Entity. That is why when I set this on the listconverter, it converts it as an AdaptiveList. My guess is an AdaptiveList.Adapter is a static method of devforce wherein you could generically set a specific list into a object(listconverter/lookupedit) only by passing a System.Collections.IList parameter.

listfields is the IList that consists of the record list I want to populate in my lookupedit.
 
AdaptiveList.Adapter(System.Collections.IList list, bool usesGlobalPropertyDescriptor)
 
This is also comes with other overloading methods :) You could also look at it in the Devforce Help, if you find my explanation a lot confusing. hehe :)


Posted By: Linguinut
Date Posted: 12-Dec-2007 at 7:08pm

Nope, not confusing, at all.  I appreciate it.  Many thanks! Thumbs%20Up

Is it possible to simply throw the "listfields" at the DataSource property?  Since it inherits from IList, it should work.  I'll have to see what this AdaptiveList offers.  It is intriguing me. 



Posted By: mykel
Date Posted: 12-Dec-2007 at 7:22pm
yes but when I did that, I could not see the list and the value, since the Object type of the listfields is not the same with the object type of data source initially set in the LookUpEdit :)


Posted By: mykel
Date Posted: 12-Dec-2007 at 7:23pm
Also, when I tried to step into the code, I noticed that the Object type currently set in my datasource is an AdaptiveList Object Type. That's why I came up in using the AdaptiveList as a primary datasource, instead. :)


Posted By: Linguinut
Date Posted: 20-Dec-2007 at 3:56pm
Just FYI...I never did figure any of this out.  My lists are a huge, unmanageable mess when trying to get a ListConverter to operate apart from binding through a ControlBindingManager.


Posted By: HFloyd
Date Posted: 01-Sep-2008 at 10:18pm
I am also trying to get an unbound combo box that uses an entity as its source...

I hacked this together after reading your posts...

(Yes this is in the xxView.cs file, I'll care about MVP when I can get something that just plain works!)


   protected override void OnLoad(EventArgs e) {
      if ( UIDesignMode.IsDesignMode ) return;
      base.OnLoad(e);
      InitializeNavTaskLinkControl();

      mAuctionYearsComboBox.Properties.DisplayMember = EntityPropertyDescriptors.AuctionYear.Year.Name;
      mAuctionYearsComboBox.Properties.ValueMember = EntityPropertyDescriptors.AuctionYear.AuctionYearGUID.Name;

      string strLCName = ListConverterNames.AuctionYears;
      ListConverterService LCService = new ListConverterService();
      IList lstAuctionYears;
      lstAuctionYears = (LCService.Get(strLCName, true)).List;
      mAuctionYearsComboBox.Properties.DataSource = IdeaBlade.Util.AdaptiveList.Adapter(lstAuctionYears, true);
    }


This code compiles fine, but crashes on run:

System.NullReferenceException was unhandled by user code
      Message="Object reference not set to an instance of an object."
      Source="IdeaBlade.Cab.UI"
      StackTrace:
       at IdeaBlade.Cab.UI.Services.ListConverterServiceBase.get_EntityManager()
       ...


VS's suggestion is : Use the "new" keyword to create an object instance.

Huh. I thought I did that...

If I try to use code more like Bill's:

string strLCName = ListConverterNames.AuctionYears;
      IList lstAuctionYears;
      ListConverter myListConverter = ListConverterService.Get(strLCName, true);
      lstAuctionYears = myListConverter.List;
      mAuctionYearsComboBox.Properties.DataSource = IdeaBlade.Util.AdaptiveList.Adapter(lstAuctionYears, true);


I get a build error (on the bolded line):
An object reference is required for the non-static field, method, or property 'IdeaBlade.Cab.UI.Services.RegistryServiceBase<IdeaBlade.UI.ListConverter>.Get(string, bool)'

Have either of you figured this one out?

Thanks!

Heather



Posted By: Linguinut
Date Posted: 02-Sep-2008 at 4:56am

Hi Heather,

Never did figure any of that out.  I left DevForce behind at the beginning of the year---haven't touched it since.  Hopefully, someone from the DF support group will be able to help you on this.  If a solution is found, go ahead and post it here...I'd still like to see how it gets resolved.
 
Take care,
Bill



Print Page | Close Window