![]() |
【转帖】mtext.textstyle怎么用
mtext.textstyle怎么用
www.dimcax.com mtext.textstyle怎么用 rt, 比如说我想设置属性为宋体 请参考... dim txtstylename as string="宋体" dim gettxtstyle as textstyletablerecord '--字型表纪录 dim trs as transaction = db.transactionmanager.starttransaction '--**以下获得或设定字体类型 tt = trs.getobject(db.textstyletableid, openmode.forwrite) '--获得字型表 if tt.has(txtstylename) then '--如果存在该字体 gettxtstyle = trs.getobject(tt(txtstylename), openmode.forread) '--获得字型表纪录 trs.commit() else gettxtstyle = new textstyletablerecord '--如果不存在该字体,设定新字体 gettxtstyle.name = txtstylename tt.add(gettxtstyle) trs.addnewlycreateddbobject(gettxtstyle, true) trs.commit() end if trs.dispose() mtext.txtstyle=gettxtstyle.objectid '--将字型赋予文字实体 忘了。。。 前面添加:dim td as textstyletable 呵呵,太感,不知道说什么好 public static objectid setfont() { objectid fontid; database db=hostapplicationservices .workingdatabase ; transaction trans = db.transactionmanager.starttransaction(); textstyletable tt = (textstyletable )trans.getobject(db.textstyletableid, openmode.forwrite); if (tt.has("宋体")) { fontid = tt["宋体"]; } else { textstyletablerecord gettxtstyle = new textstyletablerecord(); gettxtstyle.name = "宋体"; //tt.add(gettxtstyle); fontid = tt.add(gettxtstyle); trans.addnewlycreateddbobject(gettxtstyle, true); } trans.commit(); trans.dispose(); return fontid; }//设置字体; 上面是我改写的c#代码,但是有个问题,就是不论我设置宋体还是其他,出现的都是宋体,为什么啊 错了错了 我看了下这代码,感觉不对头啊这里的textstyletable应该是字体样式表,默认的有一个standard(标准)的textstyletablerecord ,你的代码是给textstyletable添加了一个名为“宋体”的textstyletablerecord,却不是设置的字体! 不过怎么在代码里设置字体,我也没找到这个属性。还要请高手赐教! 给你参考: ''' <summary>创建新文字样式,如果文字样式已存在,则返回该文字样式id。</summary> ''' <param name="textstylename">文字样式名称.</param> public shared function createtextstyle(byval textstylename as string) as objectid dim layerid as objectid dim db as database = hostapplicationservices.workingdatabase using trans as transaction = db.transactionmanager.starttransaction() dim lt as textstyletable = trans.getobject(db.textstyletableid, openmode.forread) if lt.has(textstylename) then layerid = lt.item(textstylename) else dim ltr as textstyletablerecord = new textstyletablerecord() ltr.name = textstylename ltr.filename = "txt.shx"'字体名 ltr.bigfontfilename = "gbcbig.shx" lt.upgradeopen() layerid = lt.add(ltr) trans.addnewlycreateddbobject(ltr, true) end if trans.commit() end using return layerid end function 复制代码 嗯,有实验了一下,应该是gettxtstyle.name = "宋体";改为gettextsyle.fontname="宋体"; |
所有的时间均为北京时间。 现在的时间是 05:18 AM. |