[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 589
  • Last Modified:

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.
0
Sharam_Sadi
Asked:
Sharam_Sadi
  • 3
  • 3
  • 3
  • +1
1 Solution
 
Bob LearnedCommented:
Where would you like this List to live?  On a form?  In a designer?  Run-time?  Design time?

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

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

Bob
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Sharam_SadiAuthor Commented:
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.
0
 
AgariciCommented:
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.
0
 
Bob LearnedCommented:
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
0
 
Sharam_SadiAuthor Commented:
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

0
 
AgariciCommented:
if you want to see two columns at the same time you can simply belect them concatenated into the same field from the database and have the combobox bind that mixed field as a 'DisplayMember" and the data that you need into your program as 'ValueMember'

somethind like :
fill the table with a select like this: select name+' '+surname as FullName, ID as Value from ATable

and bind to the combox like this
YourCombo.Datasource = ADotNETTable;
YourCombo.DisplayMember = "FullName";
YourCombo.ValueMember = "Value";

to see what is selected at a given time you have to use
'SelectedItem' to get the selected datatable row as a datarowview
SelectedValue to get the 'value' column from the selected row
SelectedIndex to get the index of the selected row in the datatable.

an other option would be to have an owner drawn combobox list and draw yourself in the drop down list the data columns from the table that need to be shown.

hth,
A.
0
 
caner_elciCommented:
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
0
 
caner_elciCommented:
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
0
 
Sharam_SadiAuthor Commented:
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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now