Was making a very simple text editor for practice, got the form all setup but then when I started to add the code all of the form components suddenly disappeared from the form but the still exist somewhere. Not really sure what is going on.
I have posted the code I have written so far. Alot of the features are likely going to be removed as I want this text editor to follow a free writing style. I really only plan to use the "File" drop down selection (New, Open, Save and Exit).
Thank in advance for any assistance.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CustomTextEditor2 {
public partial class TextEditor : Form {
public TextEditor() {
InitializeComponent();
}
#region Editor and General
#endregion
#region MainMenu
#endregion
#region Toolbar
#endregion
#region contextmenu
#endregion
#region Methods
#region file
void New()
{
Document.Clear();
}
void Open()
{
if (openWork.ShowDialog() == DialogResult.OK)
{
Document.LoadFile(openWork.FileName, RichTextBoxStreamType.PlainText);
}
}
void Save()
{
if (saveWork.ShowDialog() == DialogResult.OK)
{
try
{
Document.SaveFile(saveWork.FileName, RichTextBoxStreamType.PlainText);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
void Exit()
{
Application.Exit();
}
#endregion
#region edit
#endregion
#region tools
void customise()
{
ColorDialog myDialog = new ColorDialog();
if (myDialog.ShowDialog() == DialogResult.OK)
{
mainMenu.BackColor = myDialog.Color;
Status.BackColor = myDialog.Color;
Tools.BackColor = myDialog.Color;
}
}
#endregion
#endregion
}
}
Okay here is the code from TextEditor.Designer.cs:
namespace CustomTextEditor2
{
partial class TextEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// TextEditor
//
this.ClientSize = new System.Drawing.Size(732, 434);
this.MinimumSize = new System.Drawing.Size(748, 473);
this.Name = "TextEditor";
/this.Load += new System.EventHandler(this.TextEditor_Load_1);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.MenuStrip mainMenu;
private System.Windows.Forms.RichTextBox Document;
private System.Windows.Forms.StatusStrip Status;
private System.Windows.Forms.ToolStripMenuItem mM_File;
private System.Windows.Forms.ToolStripMenuItem file_New;
private System.Windows.Forms.ToolStripMenuItem file_Open;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator;
private System.Windows.Forms.ToolStripMenuItem file_Save;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem file_Exit;
private System.Windows.Forms.ToolStripStatusLabel charCount;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripStatusLabel zoom;
private System.Windows.Forms.OpenFileDialog openWork;
private System.Windows.Forms.SaveFileDialog saveWork;
private System.Windows.Forms.Timer timer;
}
}
Related
So, I was creating a windows service and i was following this video to setup the windows service.
https://www.youtube.com/watch?v=tAF9krJu3cs
So, I have a Model, I get the Model in the controller so I can build what I want to send, then, I call that Controller on the Service. After that, I created the Installer. Problem: I have 3 and i was able to create them adding: [RunInstaller(true)] in the beggining of every service. After that, I was saying that they were not manual and "prepraring" them for the errors, starting them, and, after that I started them. But, I turned on one of them, the other turns off, and so on. I was able to turn the 3 on after a while (maybe this was a bug) but they all stopped working again..... My code:
ProjectInstaller:
enter image description here
ProjectInstaller.Designer.cs :
{
partial class ProjectInstaller
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.AccountService = new System.ServiceProcess.ServiceInstaller();
this.FinInfoPrevYearService = new System.ServiceProcess.ServiceInstaller();
this.GetFinancialInfoService = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
this.serviceProcessInstaller1.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.serviceProcessInstaller1_AfterInstall);
//
// AccountService
//
this.AccountService.ServiceName = "AccountService";
this.AccountService.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.AccountService_AfterInstall);
//
// FinInfoPrevYearService
//
this.FinInfoPrevYearService.ServiceName = "FinInfoPrevYearService";
this.FinInfoPrevYearService.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.FinInfoPrevYearService_AfterInstall);
//
// GetFinancialInfoService
//
this.GetFinancialInfoService.ServiceName = "GetFinancialInfoService";
this.GetFinancialInfoService.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.GetFinancialInfoService_AfterInstall);
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.AccountService,
this.FinInfoPrevYearService,
this.GetFinancialInfoService});
}
#endregion
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller AccountService;
private System.ServiceProcess.ServiceInstaller FinInfoPrevYearService;
private System.ServiceProcess.ServiceInstaller GetFinancialInfoService;
}
}
ProjectInstaller.cs:
{
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
private void serviceProcessInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
}
private void AccountService_AfterInstall(object sender, InstallEventArgs e)
{
}
private void GetFinancialInfoService_AfterInstall(object sender, InstallEventArgs e)
{
}
private void FinInfoPrevYearService_AfterInstall(object sender, InstallEventArgs e)
{
}
}
}
One of the services:
enter image description here
Please help me guys.. I dont know what to do anymore...
I have read through a few threads here, but have not come to any conclusion.
An asynchronous method in another class is to be executed by button click.
In this method the current state should be added again and again in a text field of the form:
public interface MainForm {
string LogText { get; set; }
}
public partial class KatalogForm : Form, MainForm {
public string LogText {
get { return rtbxLog.Text; }
set { rtbxLog.Text += value; }
}
private void btnCreateCatalogues_Click(object sender, EventArgs e) {
Task.Run(() => catalogues.Create());
}
}
Excerpt from the second class:
private static MainForm mainForm;
public async void Create() {
//Stuff
//Update TextBox
}
Since the method is asynchronous, I can't access the textbox directly here.
I know that I have to work with Invoke here, but I can't implement this properly.
What is the best way to solve this?
Usually, when I have to asynchronously update a TextBox with data from external sources (ex: an operations log) I use a queue and a timer (Windows.Forms).
The method called by external objects adds the new data.
The timer clears pending data at a reasonable rate and updates the text box.
The advantages are:
Fast requests: The update method invoked by external sources only add items to the queue.
Thread safe: The text box is only updated within its own UI thread, so no cross-thread errors can occur.
Less allocations: No Task or BeginInvoke calls are required, avoiding allocation of temporary objects.
Few UI updates: The items are applied to the text box as batches (multiple items at the same time) based on the timer frequency.
First-in/First-out: No risk of overlap of items due to asynchronous operations scheduled and executed in the wrong order.
See the sample class (LogBox user control) below, split into LogBox.cs and LogBox.Designer.cs:
Other objects would call Log method.
The default rate is 100ms; that is, 10 times a second (for a human reader should be enough).
Sample code (LogBox.cs):
using System;
using System.Collections.Concurrent;
using System.Windows.Forms;
namespace SAMPLE
{
[Docking(DockingBehavior.Ask)]
public partial class LogBox : UserControl
{
private readonly ConcurrentQueue<string> PendingLog = new ConcurrentQueue<string>();
public LogBox()
{
InitializeComponent();
}
private void tmrLog_Tick(object sender, EventArgs e) { this.ProcessPendingLog(); }
private void ProcessPendingLog()
{
if (!this.Disposing && !this.IsDisposed && this.IsHandleCreated)
try
{
if (!this.PendingLog.IsEmpty)
{
string item;
while (this.PendingLog.TryDequeue(out item))
{
txtLog.AppendText(item);
}
}
}
catch (Exception ex) { /* ... */ }
}
public void Log(string text) { this.PendingLog.Enqueue(text); }
}
}
Sample code (LogBox.Designer.cs):
namespace SAMPLE
{
partial class LogBox
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.tmrLog = new System.Windows.Forms.Timer(this.components);
this.txtLog = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// tmrLog
//
this.tmrLog.Enabled = true;
this.tmrLog.Tick += new System.EventHandler(this.tmrLog_Tick);
//
// txtLog
//
this.txtLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtLog.Location = new System.Drawing.Point(0, 0);
this.txtLog.Multiline = true;
this.txtLog.Name = "txtLog";
this.txtLog.ReadOnly = true;
this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtLog.Size = new System.Drawing.Size(200, 200);
this.txtLog.TabIndex = 0;
//
// LogBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.txtLog);
this.Name = "LogBox";
this.Size = new System.Drawing.Size(200, 200);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Timer tmrLog;
private System.Windows.Forms.TextBox txtLog;
}
}
I would recommend use IProgress<string> for catalogues.Create()
Task.Run(async () =>
{
var createProgress = new Progress<string>(ReportProgress);
await catalogues.Create(createProgress);
});
void ReportProgress(string reportMessage)
{
//update log here
}
usage inside Create
async Task Create(IProgress<string> progress)
{
foreach (var category in categories)
{
// some staff
progress.Report($"{category} - completed");
}
}
IProgress example
I've made some pre-built tab pages that inherit from the systems.windows.forms.tabpage class to help cluster relevant elements and improve flexibility and readability. The problem is that in doing this, I made it so that I can't loop through the tabcontrol's pages when I want that specific tabpage layout by using foreach. I get the following error:
"System.InvalidCastException: 'Unable to cast object of type 'System.Windows.Forms.TabPage' to type 'GraphicProject.ProductionTabPage'.'"
What are some of the options I have to get fix this issue that allow me to continue making these pre-built components? Code below.
Form Designer Code
using System;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
namespace FlowCal_Time_Analyzer
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabControl1.SuspendLayout();
this.tabControl1.Controls.Add(new System.Windows.Forms.TabPage());
this.tabControl1.Controls.Add(new ProductionTabPage());
foreach (ProductionTabPage PTG in tabControl1.TabPages) //failure happens here on first element
{
PTG.Initialize();
}
this.tabControl1.ResumeLayout(false);
}
}
}
TabPage Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using LiveCharts;
using LiveCharts.Wpf;
using System.Threading;
namespace FlowCal_Time_Analyzer
{
class ProductionTabPage : TabPage
{
private Button GetProductionDataButton = new Button();
private DateTimePicker ProductionDatePicker = new DateTimePicker();
private DateTime m_selectedDate;
public void Initialize()
{
this.ProductionDatePicker.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ProductionDatePicker.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.ProductionDatePicker.Location = new System.Drawing.Point(83,4);
this.ProductionDatePicker.Margin = new System.Windows.Forms.Padding(2);
this.ProductionDatePicker.Name = "GraphDatePicker";
this.ProductionDatePicker.Size = new System.Drawing.Size(96, 20);
this.ProductionDatePicker.TabIndex = 1;
this.ProductionDatePicker.ValueChanged += new System.EventHandler(this.dateTimePicker1_ValueChanged);
this.ProductionDatePicker.MouseUp += new System.Windows.Forms.MouseEventHandler(this.GraphDatePicker_MouseUp);
this.GetProductionDataButton.Location = new System.Drawing.Point(4, 4);
this.GetProductionDataButton.Name = "GetProductionDataButton";
this.GetProductionDataButton.Size = new System.Drawing.Size(75, 23);
this.GetProductionDataButton.TabIndex = 0;
this.GetProductionDataButton.Text = "Get Device Count";
this.GetProductionDataButton.UseVisualStyleBackColor = true;
this.GetProductionDataButton.Click += new System.EventHandler(this.GetProductionDataButton_Click);
this.Controls.Add(ProductionDatePicker);
this.Controls.Add(GetProductionDataButton);
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
m_selectedDate = ProductionDatePicker.Value.Date;
}
private void GraphDatePicker_MouseUp(object sender, MouseEventArgs e)
{
ProductionDatePicker.Select();
SendKeys.Send("%{DOWN}");
}
private void GetProductionDataButton_Click(object sender, EventArgs e)
{
DBProductionModule dB_Production = new DBProductionModule();
dB_Production.GetProductionData(m_selectedDate);
}
}
}
I've attempt to follow MSDN simple make a service instructions
Walkthrough: Creating a Windows Service Application in the Component Designer
https://msdn.microsoft.com/en-us/library/zt39148a(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
namespace WindowsService1
{
public partial class Service1 : ServiceBase
{
private System.ComponentModel.IContainer components;
private System.Diagnostics.EventLog eventLog1;
public Service1()
{
InitializeComponent();
eventLog1 = new System.Diagnostics.EventLog();
if (!System.Diagnostics.EventLog.SourceExists("MySource"))
{
System.Diagnostics.EventLog.CreateEventSource("MySource", "MyNewLog");
}
eventLog1.Source = "MySource";
eventLog1.Log = "MyNewLog";
}
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart");
}
protected override void OnStop()
{
}
}
}
I seem to fail at the 2nd hurdle, "Adding Features to the Service"
When I compile I get Ambiguity between 'WindowsService1.Service1.eventLog1' and 'WindowsService1.Service1.Service1.eventLog1' and The type 'WindowsService1.Service1' already contains a defintion for 'components'
Thanks for the comments people got me looking in the right place, seems that you don't need to do step4 it is done automatically when you add the eventlog in the design view.
Service1.designer.cs looks like this
namespace WindowsService4
{
partial class Service1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.eventLog1 = new System.Diagnostics.EventLog();
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
//
// Service1
//
this.ServiceName = "Service1";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
}
#endregion
private System.Diagnostics.EventLog eventLog1;
}
}
I have a specific user control with several properties, including one which is of another class. That class contains a public int[,] this[int x, int y] (I don't remember the exact term for that) as well as a public int[,] property and a private int[,] field. I then have a form containing that control. Whenever I attempt to edit the form and then save, it denies me from saving with the following popup appearing 3 to 6 times in a row:
Note that I don't need the information saved into these arrays in the designer; the value is set to a default each time anyways within the ExampleControl. I don't even have the ability to modify or see these arrays.
Here's all of the code needed to reproduce:
Create a new form application, and then delete the Form1.cs file generated.
Program.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace ArrayRankIssue
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ExampleForm());
}
}
}
ExampleClass.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArrayRankIssue
{
public class ExampleClass
{
private int[,] data = new int[2, 2];
public int[,] Data {
get {
return data;
}
set {
if (value.GetLength(0) != data.GetLength(0) || value.GetLength(1) != data.GetLength(1)) {
throw new ArgumentException("Argument must match size of array exactly.");
}
data = value;
}
}
public int[,] this[int x, int y] {
get {
return data;
}
set {
if (value.GetLength(0) != data.GetLength(0) || value.GetLength(1) != data.GetLength(1)) {
throw new ArgumentException("Argument must match size of array exactly.");
}
data = value;
}
}
}
}
ExampleControl.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ArrayRankIssue
{
public partial class ExampleControl : UserControl
{
internal ExampleClass example = new ExampleClass();
public ExampleClass Example {
get {
return example;
}
set {
example = value;
}
}
public ExampleControl() {
InitializeComponent();
}
}
}
ExampleControl.Designer.cs:
namespace ArrayRankIssue
{
partial class ExampleControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}
ExampleForm.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ArrayRankIssue
{
public partial class ExampleForm : Form
{
public ExampleForm() {
InitializeComponent();
}
}
}
ExampleForm.Designer.cs:
namespace ArrayRankIssue
{
partial class ExampleForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
ArrayRankIssue.ExampleClass exampleClass8 = new ArrayRankIssue.ExampleClass();
this.exampleControl1 = new ArrayRankIssue.ExampleControl();
this.SuspendLayout();
//
// exampleControl1
//
this.exampleControl1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.exampleControl1.Example = exampleClass8;
this.exampleControl1.Location = new System.Drawing.Point(12, 12);
this.exampleControl1.Name = "exampleControl1";
this.exampleControl1.Size = new System.Drawing.Size(150, 150);
this.exampleControl1.TabIndex = 0;
//
// ExampleForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.exampleControl1);
this.Name = "ExampleForm";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
private ExampleControl exampleControl1;
}
}
After creating all of these files, select Build-->Rebuild solution [note 1]. Then, double-click ExampleForm.cs, click on the outlined control, and then press left and then right on your keyboard [note 2]. Then, press Control and S, and you will be greeted with the same error message many times.
What I'm looking for is a way to keep this message from popping up (and hopefully to solve the reason why it is popping up, not just suppress it). I have found a simple workaround, which is to close the form designer window and then save, but that seems impractical. Once it is successfully saved, the form appears properly, so there also doesn't seem to be any other effects.
The one other mention of this error message was in this question, but that offered no useful solution.
Note 1: This option is only available in "Expert mode" - if you don't have it, go to Tools-->Settings-->Expert Settings)
Note 2: This is needed so that the file appears as modified by Visual Studio. If it isn't done, you can't force a second save.
Moving these lines worked for me:
From ExampleForm.Designer.cs:
ArrayRankIssue.ExampleClass exampleClass2 = new ArrayRankIssue.ExampleClass();
this.exampleControl1.Example = exampleClass2;
To ExampleForm.cs:
public partial class ExampleForm : Form
{
public ExampleForm()
{
InitializeComponent();
ArrayRankIssue.ExampleClass exampleClass2 = new ArrayRankIssue.ExampleClass();
this.exampleControl1.Example = exampleClass2;
}
}
Solution 2
If you're properties are already setup and you don't need to change them mark them with:
[ReadOnly(true)]
[Browsable(false)]
In your example add those attributes to Data and this in ExampleClass.cs.
You'll have to change your code, remove any existing controls from your form, compile then re-add