ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SheetBeforeDoubleClick and merged cells (https://www.excelbanter.com/excel-programming/391496-sheetbeforedoubleclick-merged-cells.html)

Aale de Winkel

SheetBeforeDoubleClick and merged cells
 
Dear Reader

I succesfully implemented SheetBeforeDoubleClick (Excell application level)
using VSTO end VS 2005 (professional)
It works as long as cells ain't merged together.
when I double-click on single cells everything works as expected, however any
merged cell seems to destroy the event hookup, since after this even clicking
a single cell does not work anymore.
Thus presents I reckon a serious drawback in the layout-possibility of a
spreadsheet
with C#-implemented add-inns.

I'm currently at a loss to this issue, any idea's I welcome!

NickHK

SheetBeforeDoubleClick and merged cells
 
It could be that you code is not dealing with merged cells correctly and is
producing errors.

NickHK

"Aale de Winkel" wrote in message
...
Dear Reader

I succesfully implemented SheetBeforeDoubleClick (Excell application

level)
using VSTO end VS 2005 (professional)
It works as long as cells ain't merged together.
when I double-click on single cells everything works as expected, however

any
merged cell seems to destroy the event hookup, since after this even

clicking
a single cell does not work anymore.
Thus presents I reckon a serious drawback in the layout-possibility of a
spreadsheet
with C#-implemented add-inns.

I'm currently at a loss to this issue, any idea's I welcome!




Aale de Winkel

SheetBeforeDoubleClick and merged cells
 
.....
app.SheetBeforeDoubleClick += new
Microsoft.Office.Interop.Excel.AppEvents_SheetBefo reDoubleClickEventHandler(app_SheetBeforeDoubleCli ck);
.....
void app_SheetBeforeDoubleClick(object Sh,
Microsoft.Office.Interop.Excel.Range Target, ref bool Cancel)
{
MessageBox.Show("Hello")
}

Changed to the above to test your assumption!
and indeed you seem to be right since both single cell and merged cell yield
"hello"
so there must be something inside my eventhandler that disables it to
function!

Thanks, I'll need to study further. It is just that I see nothing in my code
that makes
use of the fact that cells aren't merged. So the deactivation is unexpected.
Will take some time to figure out what exactly deactivates the event

Thanks

"NickHK" wrote:

It could be that you code is not dealing with merged cells correctly and is
producing errors.

NickHK

"Aale de Winkel" wrote in message
...
Dear Reader

I succesfully implemented SheetBeforeDoubleClick (Excell application

level)
using VSTO end VS 2005 (professional)
It works as long as cells ain't merged together.
when I double-click on single cells everything works as expected, however

any
merged cell seems to destroy the event hookup, since after this even

clicking
a single cell does not work anymore.
Thus presents I reckon a serious drawback in the layout-possibility of a
spreadsheet
with C#-implemented add-inns.

I'm currently at a loss to this issue, any idea's I welcome!





NickHK[_3_]

SheetBeforeDoubleClick and merged cells
 
You could record a macro i Excel of the actions on the merged cells to see
the required VBA. Then translate to C#.

NickHK

"Aale de Winkel" ...
....
app.SheetBeforeDoubleClick += new
Microsoft.Office.Interop.Excel.AppEvents_SheetBefo reDoubleClickEventHandler(app_SheetBeforeDoubleCli ck);
....
void app_SheetBeforeDoubleClick(object Sh,
Microsoft.Office.Interop.Excel.Range Target, ref bool Cancel)
{
MessageBox.Show("Hello")
}

Changed to the above to test your assumption!
and indeed you seem to be right since both single cell and merged cell
yield
"hello"
so there must be something inside my eventhandler that disables it to
function!

Thanks, I'll need to study further. It is just that I see nothing in my
code
that makes
use of the fact that cells aren't merged. So the deactivation is
unexpected.
Will take some time to figure out what exactly deactivates the event

Thanks

"NickHK" wrote:

It could be that you code is not dealing with merged cells correctly and
is
producing errors.

NickHK

"Aale de Winkel" wrote in
message
...
Dear Reader

I succesfully implemented SheetBeforeDoubleClick (Excell application

level)
using VSTO end VS 2005 (professional)
It works as long as cells ain't merged together.
when I double-click on single cells everything works as expected,
however

any
merged cell seems to destroy the event hookup, since after this even

clicking
a single cell does not work anymore.
Thus presents I reckon a serious drawback in the layout-possibility of
a
spreadsheet
with C#-implemented add-inns.

I'm currently at a loss to this issue, any idea's I welcome!







Aale de Winkel

SheetBeforeDoubleClick and merged cells
 
for some reason my responses before hasn't shown up so my final solution to
the incomprehensable Redmond-logic is:

object TargetValue(Microsoft.Office.Interop.Excel.Range Target)
{
bool merged = (bool) Target.MergeCells;

if (!merged)
return Target.get_Value(Excel.XlRangeValueDataType.xlRang eValueDefault);
else
try
{
object[,] arr =
(object[,])Target.get_Value(Excel.XlRangeValueDataType.xlRan geValueDefault);
// new object[Target.Rows.Count, Target.Columns.Count];
return arr[1,1]; // VSTO logic C# should be arr[0,0] !!!
}
catch (Exception ex)
{
MessageBox.Show("TargetValue HUMBUG \r\n" + ex.ToString());
}
return null;
}


"NickHK" wrote:

You could record a macro i Excel of the actions on the merged cells to see
the required VBA. Then translate to C#.

NickHK

"Aale de Winkel" ...
....
app.SheetBeforeDoubleClick += new
Microsoft.Office.Interop.Excel.AppEvents_SheetBefo reDoubleClickEventHandler(app_SheetBeforeDoubleCli ck);
....
void app_SheetBeforeDoubleClick(object Sh,
Microsoft.Office.Interop.Excel.Range Target, ref bool Cancel)
{
MessageBox.Show("Hello")
}

Changed to the above to test your assumption!
and indeed you seem to be right since both single cell and merged cell
yield
"hello"
so there must be something inside my eventhandler that disables it to
function!

Thanks, I'll need to study further. It is just that I see nothing in my
code
that makes
use of the fact that cells aren't merged. So the deactivation is
unexpected.
Will take some time to figure out what exactly deactivates the event

Thanks

"NickHK" wrote:

It could be that you code is not dealing with merged cells correctly and
is
producing errors.

NickHK

"Aale de Winkel" wrote in
message
...
Dear Reader

I succesfully implemented SheetBeforeDoubleClick (Excell application
level)
using VSTO end VS 2005 (professional)
It works as long as cells ain't merged together.
when I double-click on single cells everything works as expected,
however
any
merged cell seems to destroy the event hookup, since after this even
clicking
a single cell does not work anymore.
Thus presents I reckon a serious drawback in the layout-possibility of
a
spreadsheet
with C#-implemented add-inns.

I'm currently at a loss to this issue, any idea's I welcome!








All times are GMT +1. The time now is 03:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com