- Welcome, Guest. Please Login or Register
MindFusion  
  We have released initial version of MindFusion.Scheduling library for HTML5 & JavaScript.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Easiest Way to Have View Only WorkBookView
Read 427 times

MindFusionUser47   Offline
YaBB Newbies
*
Posts: 4
I Love MindFusion!


   
     
 
Easiest Way to Have View Only WorkBookView
Feb 1st, 2018 at 10:53pm
 
Hi,
I have multiple worksheets in a workbook. When I use the workbookview I was wondering how I could disable any editing or moving of the cells. I don't want any direct changing of the text in cells or them to be deleted. Also I don't want the tabs for the worksheets to be renamable. Also is it possible to stop row and column resizing by user. Ultimately, what would be the best way to accomplish these goals?
Thanks,
Jacob
 
 
 
IP Logged    
 
     

Meppy   Offline
YaBB Moderator
*****
Posts: 1783
Gender: male
MindFusion support


   
     
 
Re: Easiest Way to Have View Only WorkBookView
Reply #1 - Feb 2nd, 2018 at 8:13am
 
Hi,

You can use the following set of properties and events to achieve this (workbook is a reference to the Workbook and view is a reference to the WorkbookView:

Code:
workbook.WorksheetCellChanging += (s, e) => e.Cancel = true;

view.AllowResizeCells = false;
view.AllowTabEdit = false;
view.AllowMoveHeaders = false;
view.AllowMoveCells = false;
view.AllowAutoFill = false;
view.AllowDrop = false;
view.InplaceEditStarting += (s, e) => e.Cancel = true; 


At the moment header resizing cannot be turned off. We can add this for you if it is essential for your project.

I hope this helps.

Regards,
Meppy
 
 
 
IP Logged    
 
     

Lonnie Nunweiler   Offline
YaBB Newbies
*
Posts: 5
I Love MindFusion!


   
     
 
Re: Easiest Way to Have View Only WorkBookView
Reply #2 - Mar 17th, 2018 at 4:59am
 
This is so close. I also want the background color to be Color.LightGray and the foreground color to be Color.Brown when it is view only (readonly).

I inserted this code:
view.BackColor = Color.LightGray;
view.ForeColor = Color.Brown;

But it has no effect. Am I missing some step?
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1563
Gender: male
tech.support


   
     
 
Re: Easiest Way to Have View Only WorkBookView
Reply #3 - Mar 19th, 2018 at 10:03am
 
Hi,

Do you mean changing the cells' white background and black text color? Try setting these through a row or cell range style -

Code:
//var globalStyle = activeSheet.CellRanges[0, 0, activeSheet.Columns.Count - 1, activeSheet.Rows.Count - 1].Style;
var globalStyle = activeSheet.Rows[0, activeSheet.Rows.Count - 1].Style;
globalStyle.Background = new MindFusion.Drawing.SolidBrush(Color.LightGray);
globalStyle.TextColor = Color.Brown; 



Regards,
Slavcho
Mindfusion
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print