当前位置:编程学习 > Delphi >>

delphi的控件问题

delph中,combobox1,combobox2和DBedit, combobox1 items中加入A 一般建筑工程,combobox2 items中加入了一类企业,选择好触发edit取值是23.2,不连接数据库,用代码写死
答案:

procedure TForm1.ComboBox1Change(Sender: TObject);
var
i:integer;//点的位置。
a:string;
begin
    i:=Pos('.',edit1.Text);//点出现的位置。
    a:=Copy(edit1.Text,i+1,Length(edit1.Text)-i);//截取.后面的字符(combobox2的位置)。
    edit1.Text:=inttostr((ComboBox1.itemIndex)+1)+'.'+a;//combobox1的位置+.+combobox2的位置。
end;

procedure TForm1.ComboBox2Change(Sender: TObject);
var
i:integer;//点的位置。
a:string;
begin
    i:=Pos('.',edit1.Text);//点出现的位置。
    a:=Copy(edit1.Text,1,i-1);//截取.前面的字符(combobox1的位置)。
    edit1.Text:=a+'.'+inttostr((ComboBox2.itemIndex)+1);//combobox1的位置+.+combobox2的位置。
end;

上一个:delphi的前途怎么样
下一个:delphi sql语句出错

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,