Link to home
Start Free TrialLog in
Avatar of Sharam_Sadi
Sharam_Sadi

asked on

Implement List Of Values(LOV)

Hello Experts!
Is there any code or component available to implement List Of Values(LOV like Oracle) in c# if there isn't any how we can
Implement that ,
description: List Of Values(LOV) is a concept in Oracle that when we perss  F9 key in Edit Box it will call a list that relates
to it.LOV can be populate from columns of database tables and we can choose our options from that.
thank you.
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Where would you like this List to live?  On a form?  In a designer?  Run-time?  Design time?

Bob
sounds like a combobox your list of values for the edit box....

A.
That's what it sounds like to me, too, just wanted to make sure.

Bob
Avatar of Sharam_Sadi
Sharam_Sadi

ASKER

hello.
List Of Values are in oracle developer that can connect to a textbox object and when when we press F9 in the textbox the LOV which is connected to that textbox appears but I need this feature in vc#.net windows form for more desciption I shouls say that LOV values can be populated from database.
thank you.
you have this in .net
you should use a combobox and bind it to a dataset
however, the dataset in ado.net is not directly connected to the database

you should look into ComboBox class

it has a DataSource member which you can assign a dataset or a datatable (which can be filled fom a database using a dataadapter)

hth,
A.
I don't know of anything specific in .NET or around the Internet that would provide exactly what you want, but Agarici has described a scenario that would give you what you want.

Bob
Hello Dear agarici (and experts):
The senario that you have described is a simple feature for example in oracle developer LOV we can see two or more columns this is helpful when we want to see the name and select the code of that name. End user can't memoriz all the codes of names in databse so this fiture is very important to database applications.LOVs in Oracle Developer are veri usefull built in tool to cover this feature is there any way to implement that or built in class to support it?

dear caner elci:
hello,
I am in experts-exchange becuase
I am not a businessman but I am a student and I want to learn about it so (my be) I will buy your component later

ASKER CERTIFIED SOLUTION
Avatar of Agarici
Agarici
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Okay, here is another way to do that especially when you don't want to give all control to ComboBox:

Define a class to hold your ID-Label pairs in the combo box, for example, a class named ListItem:

public class ListItem
{
    public object ID;
    public string Label = "";

    public ListItem(object id, string label)
    {
        ID = id;
        Label = label;
    }

    public override string ToString()
    {
        return Label;
    }
}

You might want to encapsulate the fields there (ID and Label), I left it this way to reduce the code length here.

Anyway, you can also add new fields for data columns as many as you want. When you add an instance of this class to a ListBox or a ComboBox, items will be displayed as what you return in ToString() method of your class. And when you need to get the ID of the item, you'll just have to cast it to your class and get/set whatever you want:

    comboBox1.Items.Add(new ListItem(42, "Sample Item 1"));

and

    ListItem li = (ListItem)comboBox1.SelectedItem;
    if( (int)li.ID == 42 )
        ...

This is a good way to implement LOV, because you're not limited to a datasource and this also is a lightweight solution compared to datasource approach.

I hope it helps,

Caner ELCI
Dear TheLearnedOne,

You're right. That's why I tried to direct the user to the solution by providing some samples and implementation guides.

Why I posted the first comment just because user asks :
"Is there any code or "component" available to implement List Of Values..."

My comment was about a "component" as a solution. But anyway, you're right about advertising thing, so you don't need to explain the reason why my comment was deleted.

Thanks,

Caner ELCI
dear agarici:
Your solution was helpfull thank you and thanks for administrator and other experts. If you have any comments on
farsi date(for example to tomorrow is 1384/1/31  (jalali calendar) I have an open question in my box.
thank you.