马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Using the Table cell selected event By Balaji Ramamoorthy
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();
- }
- }
- }
|