求教:如何合并单元格
初学C#开发AutoCAD,想使用MergeCells函数对“表格”图元的单元格进行合并,请问应该如何做?需要定制可联系我,qq:379539186 using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
namespace TableStyleEditing
{
public class Commands
{
public void UnmergeTableTitle()
{
var doc = Application.DocumentManager.MdiActiveDocument;
if (doc == null) return;
var ed = doc.Editor;
// Select a table
var peo = new PromptEntityOptions("\nSelect table");
peo.SetRejectMessage("\nMust be a table.");
peo.AddAllowedClass(typeof(Table), false);
var per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK)
return;
using (var tr = doc.TransactionManager.StartTransaction())
{
var table = tr.GetObject(per.ObjectId, OpenMode.ForWrite) as Table;
if (table != null)
{
// Get the first row
var row = table.Rows;
// If it is merged, unmerge it
if (row.IsMerged.HasValue && row.IsMerged.Value)
{
table.UnmergeCells(row);
ed.WriteMessage("\nUnmerged first row.");
}
else
{
ed.WriteMessage("\nFirst row is not merged.");
}
}
tr.Commit();
}
}
}
} var row = table.Rows;是取的第一行的区域,如何定义何意区域 Tb.MergeCells(ROWS(1))'行合并; Tb.MergeCells(Tb.Columns(2))'列合并;可是任意的单位格区域怎么定义呢 protected CellRange(
Table table,
int topRow,
int leftColumn,
int bottomRow,
int rightColumn
);
public virtual void MergeCells(
CellRange range
);
传入一个CellRange对象,要合并的行的收尾索引和要合并列的首尾索引。
页:
[1]