You have look at TableHitTestInfo, e.g. :
[CommandMethod("Eh")]
public void ExamineHitTest()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Transaction tr = db.TransactionManager.StartTransaction();
using ((tr))
{
try
{
PromptEntityOptions peo = new PromptEntityOptions("\nSelect a table: ");
peo.SetRejectMessage("\nYou must select a table: ");
peo.AddAllowedClass(typeof(Table), true);
PromptEntityResult res = ed.GetEntity(peo);
DBObject obj = tr.GetObject(res.ObjectId, OpenMode.ForWrite);
if (!(obj is Table))
{
return;
}
Table tbl = (Table)obj;
tbl.SuppressRegenerateTable(false);
PromptPointOptions ppo = new PromptPointOptions("\nPick a point within the cell to start from >>");
PromptPointResult ptres = default(PromptPointResult);
ptres = ed.GetPoint(ppo);
if ((ptres.Status != PromptStatus.OK))
{
return;
}
Point3d pickPt = ptres.Value;
TableHitTestInfo ht = default(TableHitTestInfo);
ht = tbl.HitTest(pickPt, Vector3d.ZAxis);
if (!(ht.Type == TableHitTestType.Cell))
{
ed.WriteMessage("You missed, Fraz, bro,\npick a point inside the cell only");
}
int row = ht.Row;
int col = ht.Column;
peo = new PromptEntityOptions("\nPick a Text or MText (or hit Enter to Exit): ");
peo.SetRejectMessage("\nYou must select a text or mtext: ");
peo.AddAllowedClass(typeof(DBText), false);
peo.AddAllowedClass(typeof(MText), false);
PromptEntityResult entres;
do
{
entres = ed.GetEntity(peo);
if (entres.Status != PromptStatus.OK)
{
if (entres.Status == PromptStatus.Cancel)
{
break;
}
}
else
{
Entity oent = (Entity)tr.GetObject(entres.ObjectId, OpenMode.ForRead);
// cast if object is of type Mtext
if ((oent) is MText)
{
if (row < tbl.Rows.Count)
{
MText mtx = (MText)oent;
string strval = mtx.Contents;
// tbl.SetTextString(row, col, 0, strval);// A2009
//--------- A2010: ----------------------
tbl.Cells[row, col].Contents[0].TextString = strval;// A2010
//---------------------------------------
tr.TransactionManager.QueueForGraphicsFlush();// to display newly created objects at run-time
}
else
{
Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("End of column has been reached");
break;
}
row += 1;
}
else
{
// cast if object is of type Text
if ((oent) is DBText)
{
if (row < tbl.Rows.Count)
{
DBText txt = (DBText)oent;
string strval = txt.TextString;
// tbl.SetTextString(row, col, strval);// A2009
//--------- A2010: ----------------------
tbl.Cells[row, col].Contents[0].TextString = strval;// A2010
//---------------------------------------
tr.TransactionManager.QueueForGraphicsFlush();// to display newly created objects at run-time
}
else
{
Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("End of column has been reached");
break;
}
row += 1;
}
}
}
tbl.RecomputeTableBlock(true);
} while (res.Status == PromptStatus.OK);
tbl.RecordGraphicsModified(true);
tr.Commit();
}
catch (System.Exception ex)
{
ed.WriteMessage(ex.ToString());
}
finally
{
//do nothing
}
}
}
}
}