资源描述:
《通用delphi数据库输入控件dbpanel的实现》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、通用Delphi数据库输入控件DBPanel的实现Datainputisindispensable,nomatterwhatprogramyoudevelop.Quicklycreatingabeautifulinputinterfacewillundoubtedlygreatlyimprovetheefficiencyofprogramdevelopment.Theoriginalcontrolofthesystemisoftenunsatisfactory.InDelphi,ifyoutarge
2、tafield,theoptionalcontrolhasDBLabel,DBEdit,andsoon.Ifyouhaveafulltableinput,youhaveDBGrid.UsethecontrolssuchasDbedit,usersmustarrangethepositionofeachfield,althoughcanachievetheresultthatisbeautiful,but,ifthefieldnumber,isverytroublesome.IftheDBGrid,n
3、omatterhowmanyfields,onlyonecontrolisenough,simpleissimple,butthefieldisaword,abitnotconvenienttouse.Forgeneralusers,itisconvenientandbeautifultouseformsofentry.Thisistheproblemthatthisarticleaddresses.--technicalkeyThemainfunctionofthiscontrolistoimpl
4、ementtheeditingofthedatabasefields.Ingeneralrules,thecontrolshouldcontainTdataLinkobjectsandshouldimplementaseriesofmethodsrelatedtoTdataLink;Butthatwouldcostalotofcode.Thelargertheamountofcode,themorecomplexthesystembecomesandthemorelikelyitistogowron
5、g.Theideaofthiscontrolistoimplementthemostfunctionalitywithminimalcode.So,editthedatafielddirectlyusingtheTDBComboBoxcontrol.Toimplementgenerality,afieldeditorcontrolarrayandfieldheaderarrayaremaintainedwithinthecontrol.Asfollows:Editors:anarrayofTDBCo
6、mboBox;->isusedtoeditthedatacontrolarray,dynamicallygeneratedLabels:anarrayofTLabel;->,thetitleofeachfield,dynamicallygeneratedTheadvantageofusingTDBComboBoxisthatitcannotonlyhavegeneraleditingfunctionality,butalsoaddpromptinformationtoeachfield.Thecod
7、eisasfollows:{themethod}{foraddingpromptinformationtotheIfield}ProcedureTDBPanelAddHits(ItemIndex:Integer;Hits:arrayofstring);varM,n,I:Integer;ThebeginN:=Length(Editors);M:=Length(Hits);IfItemIndex8、nd;-specificapplicationisdifferent,sothecontrolalsoneedtohaveenougheventhandlingtotheprogrammerinterface,inordertorealizethefunctionofspecificapplications.Thisrequiresdefiningcertaineventprocessingmethodsinthecontroltobeimplementedbythe