Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Make Table Header a Data Row

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
SRSDS
282 Views, 5 Replies

Make Table Header a Data Row

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

  •  Unmerge row(0) cells
  • Change row(0)'s style to "Data"
  • Hide or suppress row(0)

I can't figure out how to achieve any of the three, and can't find any thread posts successful in achieving it.

 

5 REPLIES 5
Message 2 of 6
_gile
in reply to: SRSDS

Hi,

Try:

table.Rows[0].Style = "_DATA";


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 6
SRSDS
in reply to: SRSDS

That's one of the ones I tried, but got an "eNotApplicable" error as this person  did.

Message 4 of 6
fieldguy
in reply to: SRSDS
Message 5 of 6
_gile
in reply to: SRSDS

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();
    }
}


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 6
SRSDS
in reply to: SRSDS

Thank you!

I've spent quite a long time trying to work that out. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report