The variable scintilla1 is either undeclared or was never assigned

Dec 28, 2009 at 5:53 PM


When i first start a project i see the scintilla textbox. But when i close the project and open again i get "To prevent possible data loss before loading the designer, the following errors must be resolved:" with the message "The variable scintilla1 is either undeclared or was never assigned". The compilation works fine but still can't use the Designer

I use VC# Express edition, framework 2.0

What am i doing wrong

please help


Dec 29, 2009 at 1:19 PM

I try now to make a new Form with dynamicaly creation of the textbox but it doesn't work. I can't find out what im doing wrong

This is the function i use:

private ScintillaNet.Scintilla scintilla1;

        private void createSci()
            scintilla1 = new ScintillaNet.Scintilla();
            scintilla1.AutoComplete.DropRestOfWord = true;
            scintilla1.AutoComplete.ListString = "";
            scintilla1.ConfigurationManager.CustomLocation = "cs.xml";
            scintilla1.ConfigurationManager.Language = "cs";
            scintilla1.Dock = System.Windows.Forms.DockStyle.Fill;
            scintilla1.IsBraceMatching = true;
            scintilla1.Lexing.Lexer = ScintillaNet.Lexer.Cpp;
            scintilla1.Lexing.LexerName = "cpp";
            scintilla1.Location = new System.Drawing.Point(0, 24);
            scintilla1.Margins.Left = 5;
            scintilla1.Margins.Margin0.Width = 23;
            scintilla1.Name = "scintilla1";
            scintilla1.Scrolling.EndAtLastLine = false;
            scintilla1.Scrolling.HorizontalWidth = 10000;
            scintilla1.Size = new System.Drawing.Size(718, 459);
            scintilla1.Styles.BraceBad.FontName = "Verdana";
            scintilla1.Styles.BraceLight.FontName = "Verdana";
            scintilla1.Styles.ControlChar.FontName = "Verdana";
            scintilla1.Styles.Default.FontName = "Verdana";
            scintilla1.Styles.IndentGuide.FontName = "Verdana";
            scintilla1.Styles.LastPredefined.FontName = "Verdana";
            scintilla1.Styles.LineNumber.FontName = "Verdana";
            scintilla1.Styles.Max.FontName = "Verdana";
            scintilla1.TabIndex = 5;
            scintilla1.Text = "Test";
            scintilla1.Visible = true;
            scintilla1.Enabled = true;
            this.scintilla1.TextChanged += new System.EventHandler<System.EventArgs>(this.scintilla1_TextChanged);
            this.scintilla1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.scintilla1_MouseUp);
            this.scintilla1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.scintilla1_KeyUp);


Any idea?

Dec 30, 2009 at 4:06 AM

After trying to create the control dynamically are you still getting the same error?

Regarding the error on the first post, that can happen sometimes when the control doesn't properly serialize itself when dropped onto the form. What happens is that the reference to the control scintila1 is still declared, but all the initializing code is gone. That may be the result of a bug in the ScintillaNET control, but given that you're the only one to report it I'm more inclined to think it has something to do with another control on your form misbehaving and scintilla1 is just getting the shaft from that.



Dec 30, 2009 at 11:26 AM

Thank you very much for answering


Regarding the first error

At the begining i made a copy of SciLexer.dll and ScintillaNet.dll and it worked fine. After closing my project and open again i saw only the blue-white screen indicating to error.

This made me confused


I read in a thread here that we have to make another copy of the SciLexer.dll to the system32 directory, but the reason for that is unknown.

I tried it and it worked :)


Any way i hope this here is useful for other newbie like me

Thank you for this great ScintillaNet project