Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Easiest Way to Have View Only WorkBookView (Read 3201 times)
MindFusionUser47
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 9
Location: Illinois
Joined: Jan 23rd, 2018
Easiest Way to Have View Only WorkBookView
Feb 1st, 2018 at 10:53pm
Print Post  
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
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Easiest Way to Have View Only WorkBookView
Reply #1 - Feb 2nd, 2018 at 8:13am
Print Post  
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
Select All
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
  
Back to top
 
IP Logged
 
Lonnie Nunweiler
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Feb 26th, 2018
Re: Easiest Way to Have View Only WorkBookView
Reply #2 - Mar 17th, 2018 at 3:59am
Print Post  
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?
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Easiest Way to Have View Only WorkBookView
Reply #3 - Mar 19th, 2018 at 9:03am
Print Post  
Hi,

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

Code
Select All
//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
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint