.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trying to delete table row

2 REPLIES 2
Reply
Message 1 of 3
nickg_Clearspan
1003 Views, 2 Replies

Trying to delete table row

I'm writing a method to delete table rows in AutoCAD based on the value of the first column. My code is:

 

public void deleteRow(String openingName)
{
    Transaction tr = doc.TransactionManager.StartTransaction();
    DocumentLock docLock = doc.LockDocument();
    using (tr)
    using (docLock)
    {
    if (!IsWriteEnabled || !IsReadEnabled) //Committing transactions closes everything for reading and writing so it must be reopened
    {
        tr.GetObject(this.ObjectId, OpenMode.ForRead);
       tr.GetObject(this.ObjectId, OpenMode.ForWrite);
    }

    for (int i = 1; i < NumRows; i++)
    {
        if (Cells[i, 0].GetTextString(FormatOption.ForExpression).Equals(openingName))
        {
            DeleteRows(i, 1);
        }
    }
    GenerateLayout();
    tr.Commit();
    }
}

 

However all it does is delete the values of the cells in the row, leaving an empty row. How do I remove the row itself?

2 REPLIES 2
Message 2 of 3

Merge cells

Message 3 of 3
_gile
in reply to: nickg_Clearspan

Hi,

 

The DeleteRows() method should delete the row, not only its contents.

Did you check the Row[i].CanDeleteRows property value?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost