Combobox with single char value and meaningful displayvalue

Author Message
 Posted 2/17/2012 4:33:47 AM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: Forum Members
Last Login: 5/4/2013 2:31:59 AM
Posts: 524, Visits: 30,384
I've always used BOs or Enums for my lookup combodropdowns

Now I have a backend column that is Char(1) and constrained to C D A  ( Change, Delete, Add )

I want to display those three choices to the user and bind to C D or A based on pick

Looking for the cleanest way to populate a dropdown CBO and have the bound value be C D or A and the full word displayed.

I'm sure it's not hard but it's not coming to me with 55+ hours in already on the work week w00t

BONUS Round :

Need manually populated combo that acts like a three state checkbox

Display TRUE, FALSE, NO CHANGE and have the backend value set to true, false and null

( I have defined the bit column that accepts nulls with nullable generic in the BO Mapper - Correct?)

TIA


Tags:
Post #30933
Add to Twitter Add to Facebook
 Posted 2/22/2012 7:26:57 AM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 12/30/2012 2:41:51 AM
Posts: 322, Visits: 529
Charles R Hankey (2/17/2012)

Looking for the cleanest way to populate a dropdown CBO and have the bound value be C D or A and the full word displayed.


Hi Charles.

Long time no see. How is everything going?

The way that I handle this is by using by standard lookup tables - lookup_hdr for the lookup categories and lookup_dtl for the lookups by category. Now, lookup_dtl has a varchar(10) field for a code in addition to the pk, description, display order number, acitve flag and default flag. So, in order to do what you want, you just populate the BO and display the description from lookup_dtl and bind to the code. Usually I bind to the pk, of course, but this setup is nice and flexible.

HTH.

-- Marcia
Post #30972
Add to Twitter Add to Facebook
 Posted 2/22/2012 9:46:09 AM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: Forum Members
Last Login: 5/4/2013 2:31:59 AM
Posts: 524, Visits: 30,384
Hi Marsha - Life is good - still at Dow Jones - Doing all C# now and loving it.

Here is how I ended up creating a dropdown that would bind to single character string

First created a custom class

        public class actionType  // used for cboActionToPerform
             {
             private string _actionval;
             private string _displayval;
             public string ActionVal
                 {
                 get { return _actionval; }
                 set { _actionval = value; }
                 }
             public string DisplayVal
                 {
                 get { return _displayval; }
                 set { _displayval = value; }                }
             public actionType(string actionval, string displayval)
                 {
                 _actionval = actionval;
                 _displayval = displayval;
             }
 


then in the contstructor of the form

...
 
      List<actionType> Actions = new List<actionType>();
             Actions.Add(new actionType("C""Change"));
             Actions.Add(new actionType("A""Add"));
             Actions.Add(new actionType("D""Delete"));

             this.cboAction.DataSource = Actions;
             this.cboAction.DisplayMember = "DisplayVal";
             this.cboAction.ValueMember = "ActionVal";



Working well. 


Say Hi to Andy for me.
Post #30974
Add to Twitter Add to Facebook
 Posted 2/22/2012 9:54:54 AM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: Forum Members
Last Login: 5/4/2013 2:31:59 AM
Posts: 524, Visits: 30,384
Probably should add I really could have done this with automatic get;set;
Post #30976
Add to Twitter Add to Facebook


Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.