aardio中richedit控件设置颜色,以前一直这样。
str = "颜色";
mainForm.richedit.setsel(m,m+1);
mainForm.richedit.setSelCharformat({textColor = 0XFFFFFF;backColor = 0x00});
mainForm.richedit.appendText(str);
但已经有的来选择就不好玩了
论坛就是好,有现成的,找到了,小改下贴上来。
import win.ui;
import win.dlg.findReplace;
import console;
/*DSG{{*/
mainForm = win.form(text="aardio form";right=759;bottom=469)
mainForm.add(
button2={cls="button";text="直接标记颜色";left=607;top=14;right=747;bottom=45;z=2};
richedit={cls="richedit";left=6;top=6;right=599;bottom=451;edge=1;multiline=1;vscroll=1;z=1}
)
/*}}*/
var frDlg = win.dlg.findReplace(mainForm);
var str = '这个是富文本框的替换和加标设置,看看最后效果\r\n转行看看'
var cf2 = win.ui.ctrl.CHARFORMAT2()
cf2.yHeight = 200;//设置cf2 字体高度
mainForm.richedit.print(str)
mainForm.button2.oncommand = function(id,event){
cf2.textColor = 0x00ff00;// 设置cf2 字体颜色
var replaceWith ="@加标设置";
var a,b = string.find(mainForm.richedit.text,replaceWith,1,true);
mainForm.richedit.setsel(a,b);
mainForm.richedit.setSelCharformat(cf2);
mainForm.richedit.deselect();
}
mainForm.show();
win.loopMessage();