|
If the file doesn't contain a well-formed XML document you'll need to fix it.
|
|
|
|
|
For the moment i use utf8 encoding and replace all the & with &
What are the other possible char that may cause the Exception ?
|
|
|
|
|
|
I am using abstract classes in my project, meanwhile i want to use overloaded Constructors to those classes, then how to call those overloaded constructors, because abstract classes cannot instantiate.
can any one please answer me?
Thanks in advance...
|
|
|
|
|
An abstract class can have implementations though.
public abstract class BaseClass
{
protected BaseClass()
{ }
protected BaseClass(int id)
{
ID = id;
}
public int ID
{
get;
private set;
}
public string Text
{
get;
internal set;
}
}
public class DerivedClass : BaseClass
{
public DerivedClass() : base() { }
public DerivedClass(int id) : base(id) { }
public DerivedClass(int id, string text) : base(id)
{
Text = text;
}
}
[Edit] Forgot to mark the abstract class's constructors as protected[/Edit]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Wednesday, June 17, 2009 4:57 AM
|
|
|
|
|
The same as calling any base class constructors?
|
|
|
|
|
i'm try to register a formclosing event with a button click event but i get the error saying "Cannot assign to 'button1_Click' because it is a 'method group'"
this is the code i'm using
private void Form1_FormClosing(object sender,EventArgs e)
{
DialogResult ds = MessageBox.Show("exit?", "exit", MessageBoxButtons.YesNo);
FormClosingEventArgs ee = (FormClosingEventArgs)e;
if (ds == DialogResult.Yes)
{
ee.Cancel = false;
}
else
{
ee.Cancel = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
button1_Click+= Form1_FormClosing;
}
what might be the problem here ?
|
|
|
|
|
prasadbuddhika wrote: button1_Click+= Form1_FormClosing;
well you dont add event handlers like that. try...
button1.Click += new EventHandler(Form1_FormClosing);
but your Form1_FormClosing method is just a handler and will not close the form.
what you should do is have the FormClosing handler on the Form.Closing event. Then have the button click event call
Form.Close();
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
button1_Click is a method. I think you meant button1.Click
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
oh ! great , thanx,i really deceived , thank you again.
|
|
|
|
|
in my app there is a button called exit, i want to prompt a dialog box confirming the exit.now i'm trying handle the closing event of the control box, that is why i'm trying to register the formclosing event with click event , but i get a deligate problem because of eventarg and formclosingeventarg, so any one can help me with this
|
|
|
|
|
Hi,
In your original code the signature of the delegate is incorrect
[Edit: typo corrected]
private void Form1_FormClosing(object sender, EventArgs e)
should be
private void Form1_FormClosing(object sender, FormClosingEventArgs e).
Alan.
modified on Wednesday, June 17, 2009 6:23 AM
|
|
|
|
|
This is pretty simple. You need to call Close from the button's Click event handler and display the message box or whatever in the form's FormClosing event handler, setting e.Cancel if you don't want to close:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
FormClosing += new FormClosingEventHandler(Form1_FormClosing);
btnExit.Click += new EventHandler(btnExit_Click);
}
void btnExit_Click(object sender, EventArgs e)
{
Close();
}
void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = (MessageBox.Show(
this,
"Do you really wish to exit this application?",
"Confirm Exit",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2) != DialogResult.Yes);
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I wondered about that when I saw your original code.
private void Form1_FormClosing(object sender,EventArgs e)
{
DialogResult ds = MessageBox.Show("exit?", "exit", MessageBoxButtons.YesNo);
FormClosingEventArgs ee = (FormClosingEventArgs)e;
if (ds == DialogResult.Yes)
{
ee.Cancel = false;
}
else
{
ee.Cancel = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
button1_Click+= Form1_FormClosing;
}
Are you perhaps thinking that linking the ForClosing event to a button click will cause the button to generate the FormClosing event and thus close the form? If so, that will not happen.
What you need to do in your button Click event is "this.Close()" which will close the current form. That will raise the FormClosing event where you can then ask for confirmation:
private void Form1_FormClosing(object sender,EventArgs e)
{
DialogResult ds = MessageBox.Show("exit?", "exit", MessageBoxButtons.YesNo);
if (e is FormClosingEventArgs)
{
FormClosingEventArgs ee = e as FormClosingEventArgs;
ee.Cancel = (ds == DialogResult.No);
}
}
private void Button1_Click(object sender, EventArgs e)
{
this.Close();
}
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
iam using windows application using csharp,iam design UI which will display the all characters of keyboard(lowercase,uppercase,symbols,special characters)I initialize the characters using folowing code:
code 1. private void InitializeCharacters(InkOverlay inkOverlay)
{
this.Add(new Character(inkOverlay, "0x20", "space", " ", CharClass.Hidden));
this.Add(new Character(inkOverlay, "0x21", "exclam", "!", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x22", "quotedbl", "\"", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x23", "numbersign", "#", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x24", "dollar", "$", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x25", "percent", "%", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x26", "ampersand", "&", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x27", "quotesingle", "'",CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x28", "parenleft", "(", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x29", "parenright", ")", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x2a", "asterisk", "*", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x2b", "plus", "+", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x2c", "comma", ",", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x2d", "hyphen", "-", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x2e", "period", ".", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x2f", "slash", "/", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x30", "zero", "0", CharClass.Number));
this.Add(new Character(inkOverlay, "0x31", "one", "1", CharClass.Number));
this.Add(new Character(inkOverlay, "0x32", "two", "2", CharClass.Number));
this.Add(new Character(inkOverlay, "0x33", "three", "3", CharClass.Number));
this.Add(new Character(inkOverlay, "0x34", "four", "4", CharClass.Number));
this.Add(new Character(inkOverlay, "0x35", "five", "5", CharClass.Number));
this.Add(new Character(inkOverlay, "0x36", "six", "6", CharClass.Number));
this.Add(new Character(inkOverlay, "0x37", "seven", "7", CharClass.Number));
this.Add(new Character(inkOverlay, "0x38", "eight", "8", CharClass.Number));
this.Add(new Character(inkOverlay, "0x39", "nine", "9", CharClass.Number));
this.Add(new Character(inkOverlay, "0x3a", "colon", ":", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x3b", "semicolon", ";", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x3c", "less", "<", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x3d", "equal", "=", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x3e", "greater", ">", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x4f", "question", "?", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x40", "at", "@", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x41", "A", "A", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x42", "B", "B", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x43", "C", "C", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x44", "D", "D", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x45", "E", "E", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x46", "F", "F", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x47", "G", "G", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x48", "H", "H", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x49", "I", "I", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4a", "J", "J", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4b", "K", "K", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4c", "L", "L", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4d", "M", "M", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4e", "N", "N", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4f", "O", "O", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x50", "P", "P", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x51", "Q", "Q", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x52", "R", "R", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x53", "S", "S", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x54", "T", "T", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x55", "U", "U", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x56", "V", "V", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x57", "W", "W", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x58", "X", "X", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x59", "Y", "Y", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x5a", "Z", "Z", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x5b", "bracketleft", "[", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x5c", "backslash", @"\", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x5d", "bracketright", "]", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x5e", "asciicircum", "^", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x5f", "underscore", "_", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x60", "grave", "`", CharClass.Notdef));
this.Add(new Character(inkOverlay, "0x61", "a", "a", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x62", "b", "b", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x63", "c", "c", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x64", "d", "d", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x65", "e", "e", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x66", "f", "f", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x67", "g", "g", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x68", "h", "h", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x69", "i", "i", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6a", "j", "j", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6b", "k", "k", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6c", "l", "l", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6d", "m", "m", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6e", "n", "n", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6f", "o", "o", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x70", "p", "p", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x71", "q", "q", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x72", "r", "r", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x73", "s", "s", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x74", "t", "t", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x75", "u", "u", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x76", "v", "v", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x77", "w", "w", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x78", "x", "x", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x79", "y", "y", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x7a", "z", "z", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x7b", "braceleft", "{", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x7c", "bar", "Signature ", CharClass.Signature));
this.Add(new Character(inkOverlay, "0x7d", "braceright", "}", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x7e", "asciitilde", "~", CharClass.Symbol));
}
///Above code works fine... i have used picturebox control to draw the writing area
private void drawWritingArea()
{
this.drawWritingArea(this.picBoxCharacters.Width);
}
///The error comes here when it goes into for each loop for each charset, from the code1 i get the all characters into charset it there works fine but during FOR LOOP it gives me error at charset (Stack overflow execption , please suggest me how to resolve it)//
private void drawWritingArea(int bitmapWidth)
{
Application.DoEvents();
CharClass[] classArray2 = new CharClass[6];
classArray2[1] = CharClass.Uppercase;
classArray2[2] = CharClass.Number;
classArray2[3] = CharClass.Punctuation;
classArray2[4] = CharClass.Symbol;
classArray2[5] = CharClass.Signature;
CharClass[] classArray = classArray2;
int num = 0x20;
int num2 = num / 4;
int num3 = num / 2;
int num4 = 13;
int num5 = 0x37;
int num6 = 10;
int num7 = 10;
double num8 = double.Parse(this.lblZoomFactor.Text) / 100.0;
int num9 = (int)(num * num8);
int num10 = (int)(num2 * num8);
int num11 = (int)(num3 * num8);
int width = (int)(num5 * num8);
int num13 = (int)(num6 * num8);
int height = ((num4 + num9) + num10) + num11;
int num15 = ((bitmapWidth - 0x10) - (2 * num13)) / width;
int num16 = (bitmapWidth - (2 * num6)) - (width * num15);
num16 /= 2;
int num17 = 0;
Label_0104:
foreach (Character character in this.charSet)///Error of stack overflow execption in Charset//
{
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}
int num18 = (num17 / num15) + 4;
if (this.breakCharTypes)
{
num18 += 2;
}
int num19 = num18 * (height + num13);
Bitmap image = new Bitmap(bitmapWidth, num19, PixelFormat.Format32bppArgb);
this.picBoxCharacters.Height = num19;
Graphics graphics = Graphics.FromImage(image);
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
Brush brush = new SolidBrush(Color.LightYellow);
Pen pen = new Pen(Color.LightSteelBlue);
Pen pen2 = new Pen(Color.DarkBlue, 2f);
Pen pen3 = new Pen(Color.Gainsboro);
pen3.DashStyle = DashStyle.Dash;
Brush brush2 = new SolidBrush(Color.DimGray);
int y = num13;
int num21 = 0;
for (int i = 0; i < classArray.Length; i++)
{
CharClass class3 = classArray[i];
foreach (Character character2 in this.charSet)
{
if (character2.type == class3)
{
num21++;
int num23 = num21 % num15;
if (num23 == 0)
{
num23 = num15;
}
if ((num23 == 1) && (num21 > 1))
{
y += height + num13;
}
int x = ((width * (num23 - 1)) + num13) + num16;
if (character2.type == CharClass.Signature)
{
width *= 5;
}
Rectangle rect = new Rectangle(x, y, width, height);
graphics.FillRectangle(brush, rect);
graphics.DrawRectangle(pen, rect);
int num25 = (y + num4) + num10;
graphics.DrawLine(pen2, x, num25, x + width, num25);
graphics.DrawString(character2.representation, new Font("Microsoft Sans Serif", (float)num7), brush2, (float)(x + 3), (float)y);
int num26 = num25 + num9;
graphics.DrawLine(pen2, x, num26, x + width, num26);
graphics.DrawLine(pen3, x, num25 + (num9 / 2), x + width, num25 + (num9 / 2));
Graphics g = base.CreateGraphics();
Rectangle rectangle = rect;
rectangle.Y += num4;
rectangle.Height -= num4;
character2.setPosition(rectangle, num26, num25, g, this.inkOverlay.Renderer);
if (character2.type == CharClass.Signature)
{
width /= 5;
}
}
}
if (this.breakCharTypes || ((i < (classArray.Length - 1)) && (classArray[i + 1] == CharClass.Signature)))
{
y += height + num13;
num21 = 0;
}
}
this.picBoxCharacters.Image = image;
this.picBoxCharacters.Refresh();
}
public virtual Enumerator GetEnumerator()
{
return new Enumerator(this );///iam getting error on this line An unhandled exception of type 'System.StackOverflowException' occurred ()
}
iam using INKOVERLAY(Tablet PC using CSharp) class so that i can write under all the charcaters in the drawing area, my solution build successfully , no other errors but when the form load it show the stack overflow exeception , please help me out to solve the error
waiting for possitive response
with regards
radhika
|
|
|
|
|
Take a close look to your code:
Label_0104:
foreach (Character character in this.charSet){
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}
|
|
|
|
|
I took the liberty lo link it into the Coding Horrors forum.
|
|
|
|
|
means wat sir, iam not getting wat your telling , if you could suggest any solution for it , it would be grt help of yours
|
|
|
|
|
sir,
Thanks for your suggestions, but what is wrong the for each loop , iam not getting as it will For each Character in this charset, as iam getting all the values in the charaset, iam able to initalize the characters in charset, but during looping only iam getting error
Am i using wrong method of looping foe each values or it is wrong way of using loop,please tell me the
alternate to acheive this
with regards
Radhika
|
|
|
|
|
I never use goto to exit a loop ....
|
|
|
|
|
Ok sir then wat else u use to exit the loop , my problem is that it gives me error only in the
For each loop syntax for this.charset statement, so i will try to resolve it but also suggest ur view wat should i use to exit the loop
your suggestions are really very helpful thanks alot sir for your kind suggestions
with regards
radhika
|
|
|
|
|
loops are best exited with break . If you need to know if some condition was met inside the loop, create a variable outside the loop and set it's value before calling break. You can then check that variable after the loop has completed or been broken out of.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
To elaborate on what Thomas said: take a look at your code:
Label_0104:
foreach (Character character in this.charSet) {
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}
So, you enter the first loop, enter the second, then when you find a match with class2, you go back to before the first loop and enter again.
How are you ever going to to get out of the loop? No wonder you run out of memory first!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
There is a commonly accepted statement that "goto is evil".
That my be a little extreme, but if it is to be used, it should be done with GREAT caution.
There are very few cases where goto is the best way to control program flow in modern day languages. Rewrite the code without using any goto(s) (and preferably with more descriptive variable naming) and it will be much easier to follow - and will most likely work!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Label_0104:
foreach (Character character in this.charSet)
{
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}
Stack overflows are often caused by an infinite loop in the code and that's what you have here.
When the condition character.type == class2 is true the outer loop restarts and then when the same condition is encountered for a second time, the loop restarts, and so on. I haven't read your code fully but I suspect that you meant to jump to a point after the end of the outer loop, not just before it's start.
Alan.
|
|
|
|
|