I'm inserting a standard TableStyle that has a header row and data rows beneath.
The header row is a single merged cell that I want changed to a data row.
So I need to either
I can't figure out how to achieve any of the three, and can't find any thread posts successful in achieving it.
Solved! Go to Solution.
Solved by _gile. Go to Solution.
That's one of the ones I tried, but got an "eNotApplicable" error as this person did.
i use the code in this post.
You have to set the TableStyle property before setting the Rows[0].Style.
Here's an example:
[CommandMethod("TEST")]
public static void Test()
{
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
int numRows = 4;
double rowHeight = 9.0;
int numColumns = 3;
double columnWidth = 40.0;
using (var tr = db.TransactionManager.StartTransaction())
{
var tableStyles = (DBDictionary)tr.GetObject(db.TableStyleDictionaryId, OpenMode.ForWrite);
var tableStyle = tableStyles.GetAt("Standard");
var table = new Table();
table.TableStyle = tableStyle;
table.Columns[0].Width = columnWidth;
table.InsertColumns(1, columnWidth, numColumns - 1);
table.InsertRows(1, rowHeight, numRows - 1);
for (int i = 0; i < numRows; i++)
{
table.Rows[i].Style = "_DATA";
}
table.Position = Point3d.Origin;
var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
curSpace.AppendEntity(table);
tr.AddNewlyCreatedDBObject(table, true);
tr.Commit();
}
}
Can't find what you're looking for? Ask the community or share your knowledge.