When a table cell gets selected, you may interested in knowing the row and column index of the cell that was selected.
There is no such event in the public API but the "Autodesk.AutoCAD.Internal.Reactors" does provide one such event. Please note that the use of any API which is part of the "Internal" namespace is unsupported and subject to change. So, if you decide to use it, please test it thoroughly to see if it works correctly in your plugin.
Here is the sample code to use the "CellSelected" event from the "Autodesk.AutoCAD.Internal.Reactors.TableSubSelectFilter" class.
using Autodesk.AutoCAD.Internal.Reactors;
void IExtensionApplication.Initialize()
{
TableSubSelectFilter tsf = TableSubSelectFilter.Instance();
if (tsf != null)
{
tsf.CellSelected
+= new TableSubSelectFilterEventHandler(tsf_CellSelected);
}
}
void IExtensionApplication.Terminate()
{
TableSubSelectFilter tsf = TableSubSelectFilter.Instance();
if (tsf != null)
{
tsf.CellSelected
-= new TableSubSelectFilterEventHandler(tsf_CellSelected);
}
}
void tsf_CellSelected(object sender, TableSubSelectFilterEventArgs e)
{
if (! e.TableId.IsNull)
{
using (Transaction tr
= e.TableId.Database.TransactionManager.StartTransaction())
{
Table table
= tr.GetObject(e.TableId, OpenMode.ForRead) as Table;
if (table.HasSubSelection)
{
CellRange cr = table.SubSelection;
System.Diagnostics.Debug.WriteLine
(
String.Format("\nSingle Cell ? : {0}",
cr.IsSingleCell)
);
System.Diagnostics.Debug.WriteLine
(
String.Format("\nTop row : {0}",
cr.TopRow)
);
System.Diagnostics.Debug.WriteLine
(
String.Format("\nLeft column : {0}",
cr.LeftColumn)
);
System.Diagnostics.Debug.WriteLine
(
String.Format("\nBottom Row : {0}",
cr.BottomRow)
);
System.Diagnostics.Debug.WriteLine
(
String.Format("\nRight column : {0}",
cr.RightColumn)
);
}
tr.Commit();
}
}
}