Page Index Toggle Pages: 1 [2]  Send TopicPrint
Hot Topic (More than 10 Replies) Add button in cell. (Read 6409 times)
Slavcho
God Member
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Add button in cell.
Reply #15 - Dec 21st, 2020 at 6:38am
Print Post  
Showing it in the edit UI should be possible via InplaceEditStarting event, but then the button will appear only for the currently active cell (one you can type into). Otherwise styling cells to look as in screenshot above can be done like this -

Code
Select All
var cell = activeSheet.Cells["A1"];
cell.Style.Background = new LinearGradientBrush(
    Colors.DarkSlateGray, Colors.Gray, 30);
cell.Style.BorderTopSize = 2;
cell.Style.BorderBottomSize = 2;
cell.Style.BorderLeftSize = 2;
cell.Style.BorderRightSize = 2;
cell.Style.BorderTopBrush = Brushes.Black;
cell.Style.BorderBottomBrush = Brushes.Black;
cell.Style.BorderLeftBrush = Brushes.Black;
cell.Style.BorderRightBrush = Brushes.Black;
cell.Style.HorizontalAlignment =
	MindFusion.Spreadsheet.Wpf.HorizontalAlignment.Center;
cell.Style.VerticalAlignment =
	MindFusion.Spreadsheet.Wpf.VerticalAlignment.Middle; 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
David Chiang
Junior Member
**
Offline


I Love MindFusion!

Posts: 75
Joined: Apr 15th, 2020
Re: Add button in cell.
Reply #16 - Dec 22nd, 2020 at 5:38am
Print Post  
Thanks for the answer. I can using hyperlink to hide the data behind it.

                                   string[] ev = columnsList[j].Split("^#^");

                                   var cell = activeSheet.Cells[j, x + 1];
                                   cell.Style.HorizontalAlignment = MindFusion.Spreadsheet.Wpf.HorizontalAlignment.Center;
                                   cell.Style.TextBrush = new SolidColorBrush(Color.FromRgb(240, 240, 240));
                                   cell.Style.Background = new LinearGradientBrush(
                                         Colors.DarkSlateGray, Colors.Gray, 30);
                                   cell.Style.BorderTopSize = 2;
                                   cell.Style.BorderBottomSize = 2;
                                   cell.Style.BorderLeftSize = 2;
                                   cell.Style.BorderRightSize = 2;
                                   cell.Style.BorderTopBrush = Brushes.Black;
                                   cell.Style.BorderBottomBrush = Brushes.Black;
                                   cell.Style.BorderLeftBrush = Brushes.Black;
                                   cell.Style.BorderRightBrush = Brushes.Black;
                                   cell.Style.HorizontalAlignment =
                                         MindFusion.Spreadsheet.Wpf.HorizontalAlignment.Center;
                                   cell.Style.VerticalAlignment =
                                         MindFusion.Spreadsheet.Wpf.VerticalAlignment.Middle;
                                   cell.Data = ev[0];
                                   cell.SetHyperlink(HyperlinkType.WebAddress, ev[3] + "?" + ev[4] + dataRow[ev[1]].ToString(), "");


                       workbookView.HyperlinkClicked += (sender, args) => showWindow(args.Cell.Hyperlink.Target.ToString());


Thanks

David Chiang
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint