当前位置:网站首页>Drop down selection of Ehlib database records

Drop down selection of Ehlib database records

2022-07-04 21:33:00 pcplayer

The goal is :

Select from the drop-down list , Know which record the user has selected in the database . Just to know , Instead of inputting .

There is a table , There are many records . Provide an interface for users to select a record from the table . The program obtains the user's selection results .

The easiest way , Give me a DBGrid, The user moves the cursor to the selected record ( By scrolling and clicking DBGrid A record in it ), Then the program reads its corresponding DataSet.

DBGrid Too much space . It's better to have a similar Edit Things that are , Then there is a drop-down button , Click this button , Come down and come out a box , There are multiple records in the box for users to choose . Select the result to be displayed in this Edit Inside .

use EhLib Control for , It is easier to achieve such an effect .

Method

There are two kinds of controls that can be used :

A. TDBLookupComboboxEh;

B. TDBEditEh;

hypothesis : The tables used for user selection are 2 A field :V_ID and V_Name;

The value of the data sensitive control of the interface , Not a direct read control , It is bound by the read control DataSet. therefore , In order to read the results of user selection interface controls , Must put one DataSet ad locum . Here I put one ClientDataSet1, And create... For it 3 A field :V_ID; V_Name; VName; among VName It's a Lookup Field ;

A. use  TDBLookupComboboxEh

DBLookupComboboxEh1 It has a drop-down button , This drop-down button will pull down a box . Multiple fields can be displayed in this box . About the setting of this box , Is its attribute :DropDownBox;
however , This drop-down selection box , Not as good as DropDownForm To use . because DropDownForm I can put one in it DGBridEh, More powerful , For example, one more filter input field .
To make  DBLookupComboboxEh1 The drop-down triangle button on the right , After clicking, there is a DropDownForm, Need to find its attribute :EditButton, Expand this property on the property panel , There is DropDownFormParams attribute , Expand it , You can set its DropDownForm 了 .
After setting up , Runtime , Click its triangle drop-down button , What comes out is not its own DropDownBox It's this DropDownForm 了 .
DBLookupComboboxEh1 Of DataSet Several properties of :
The goal is : Select from the drop-down list , Know which record the user has selected in the database . Just to know , Instead of inputting .
1. DataSource attribute , Corresponding DataSource And its DataSet, It's a local ClientDataSet, It is only used to carry the results of user selection . It has three fields :V_ID; V_Name; VName; among VName It's a Lookup Field ;
2. DataField attribute , Corresponding V_ID Field ;
3. ListSource attribute , For applications that allow users to select multiple records DataSet;
4. ListField attribute , It's for DropDownBox The fields displayed inside . Of course , If it is specially set DropDownBox Some attribute settings under attributes , You can add several fields . That is, you can see the display of several more fields after dropping down .
5. If the DropDownForm, Maybe the above ListSource The setting of ?

About EhLib Of DropDownForm, I won't explain it in detail here .EhLib Self contained Demo There is its example code .

I also wrote an article , Talk about DropDownForm Usage of , The address is :

https://blog.csdn.net/pcplayer/article/details/113873604

B. use DBEditEh:

Use DBEditEh1 You can also pull down DropDownForm Let the user choose the effect of a record , Doing this :
1. The most important point , This DBEditEh1 Of DataField To point to VName This Lookup Field , instead of V_Name This field ; Otherwise, it does not display ;
2. DBEditEh1 Of DataSource It also implements the above local ClientDataSet;
3. In the property panel , Find it. EditButtons term , Double clicking will pop up a small window , Used to add buttons . Right click in the small window and select Add after , A button will come out . Select the newly added button in the small window , There are DropDownFormParams term , Expand this , You can set a DropDownForm;


Complete the above settings , You can go to DBEditEh1 Inside , Also see a drop-down button , Pull down and pop up DropDownForm.

原网站

版权声明
本文为[pcplayer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207042033575217.html