回复 1楼pjsLucky的帖子
pjsLucky 你好
Spread WPF-Silverlight本身设计时不支持这样的使用方式,不过可以尝试使用以下方法来解决这一问题
- this.gcSpreadsheet1.MouseLeftButtonDown += OnGcSpreadsheetMouseLeftButtonDown;
- private void gcSpreadsheet1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- SheetTab sheetTab = null;
- var popups = VisualTreeHelper.GetOpenPopups();
- if (popups != null && popups.Count() > 0)
- {
- foreach (var popup in popups)
- {
- if (popup.Child is ChildWindow)
- {
- var point = e.GetPosition(popup.Child);
- var hitElements = VisualTreeHelper.FindElementsInHostCoordinates(point, popup).ToList<UIElement>();
- if (hitElements == null || hitElements.Count == 0)
- return;
- foreach (var element in hitElements)
- {
- if (element is SheetTab)
- {
- sheetTab = (SheetTab)element;
- break;
- }
- }
- }
- }
- }
-
- if (sheetTab != null)
- {
- if (sheetTab.SheetIndex >= 0)
- {
- this.gcSpreadsheet1.ActiveSheetIndex = sheetTab.SheetIndex;
- }
- else //Click on the New sheettab, insert a new worksheet and set the index to the new added sheet.
- {
- this.gcSpreadsheet1.Workbook.Sheets.Insert(this.gcSpreadsheet1.SheetCount, new GrapeCity.Windows.SpreadSheet.Data.Worksheet());
- this.gcSpreadsheet1.ActiveSheetIndex = this.gcSpreadsheet1.SheetCount - 1;
- }
- }
- }
复制代码 |