Combobox with single char value and meaningful displayvalue


Author
Message
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
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
Marcia G Akins
Marcia G Akins
StrataFrame User (432 reputation)StrataFrame User (432 reputation)StrataFrame User (432 reputation)StrataFrame User (432 reputation)StrataFrame User (432 reputation)StrataFrame User (432 reputation)StrataFrame User (432 reputation)StrataFrame User (432 reputation)StrataFrame User (432 reputation)
Group: StrataFrame Users
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
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
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.
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)Advanced StrataFrame User (764 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Probably should add I really could have done this with automatic get;set;
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search