uniGUI制作標簽
有這樣的需求,要實現這樣的樣式:

1.為了實現,寫一個函數
function AddLabel(aJsName,aEventName,aID,aCaption:string):string; begin result:= Format('<a class="btnopbtn" style="color: #148a14" onclick="ajaxRequest(%s,''%s'',[''id=%s'']);">%s</a>|',[aJsName,aEventName,aID,aCaption]); end;
2.放一個uniLable,并設置他的TextConversion為txtHTML
3.為uniLabel設置值:
label1.Text:=AddLabel(Label1.JSName,'add','id1','增加')+ AddLabel(Label1.JSName,'editrow','id2','編輯');
4.處理Label.OnAjaxEvent事件:
procedure TMainForm.Label1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
var
id:string;
begin
//
if EventName='add' then
begin
id:=Params.Params['id'].AsString;
ShowMessage('add:'+id);
end;
if EventName='editrow' then
ShowMessage('editrow');
end;
當然你也可以通過Params進一步傳參數到這個事件中。
浙公網安備 33010602011771號