|
the-Yetti wrote: I have a 'new person' form that i want to start with a height of 276 and if the person will have a photo the form to open up to 440. So for eas of working with it, in the designer it is 440 high, but I want it to open with 276. So I figured...
public frmNewPerson () {
InitializeComponent ();
Form.ActiveForm.Height=276;
}
would work, but it doesn't, it says...
Message="Object reference not set to an instance of an object."
and highlights the line Form....
So am I just putting this line of code in the wrong place or what?
As you are in the constructor of the form, the ActiveForm property hasn't been initialised yet.
Try
this.Height = 276;
|
|
|
|
|
Put it in the Form's Load event instead of constructor.
private void frmNewPerson_Load(object sender, EventArgs e)
{
this.Height = 276;
}
|
|
|
|
|
That's what I thought, but I had tried ( as suggested by engsrini ) that I try it in the Load event, but it still failed. But thanks this.Height works.
|
|
|
|
|
Hi .
Need to Convert base64 string representing header of the binary field with image data.
//ds.Tables[6].Rows[1].ItemArray[2].ToString() contains base64string
{
Byte[] byt = Convert.FromBase64String(ds.Tables[6].Rows[1].ItemArray[2].ToString());
SaveToOut("image/jpeg", byt, true);
PerformScaleImage(contentType, content, Response, 150, 50);
MemoryStream stream = new MemoryStream();
stream.Write(buff, 0, buff.Length);
using (Bitmap img = new Bitmap(stream))/*---Giving invalid parameter exception-------*/
{
--------------------------}
}
Can you give details.
Srinivas
|
|
|
|
|
The error comes because you haven't reset the memory stream before reading it.
You should create a read-only memory stream from the array instead:
MemoryStream stream = new MemoryStream(buff, false);
Now the memory stream contains the data from the start, and you can read from it right away.
---
Year happy = new Year(2007);
|
|
|
|
|
The error is at the line pointing to ------(A)
MemoryStream stream = new MemoryStream();
stream.Write(buff, 0, buff.Length);
------(A)
using (Bitmap img = new Bitmap(stream))/*---Giving invalid parameter exception-------*/
{
--------------------------}
}
Srinivas S
|
|
|
|
|
Yes, I know that. Read my previous post again, and you might realise that.
---
Year happy = new Year(2007);
|
|
|
|
|
MemoryStream stream = new MemoryStream(buff, false);
After that also its giving same one
Invalid parameter for bitmap constructor.
|
|
|
|
|
I have tested it, and as expected it works just fine.
Where do you create the array buff , and what does it contain?
---
Year happy = new Year(2007);
|
|
|
|
|
Hi .
Need to Convert base64 string representing header of the binary field with image data.
//ds.Tables[6].Rows[1].ItemArray[2].ToString() contains base64string
{
Byte[] byt = Convert.FromBase64String(ds.Tables[6].Rows[1].ItemArray[2].ToString());
SaveToOut("image/jpeg", byt, true);
PerformScaleImage(contentType, content, Response, 150, 50);
MemoryStream stream = new MemoryStream();
stream.Write(buff, 0, buff.Length);
using (Bitmap img = new Bitmap(stream))/*---Giving invalid parameter exception-------*/
{
--------------------------}
}
Can you give details.
Srinivas S
|
|
|
|
|
Hi .
Need to Convert base64 string representing header of the binary field with image data.
//ds.Tables[6].Rows[1].ItemArray[2].ToString() contains base64string
{
Byte[] byt = Convert.FromBase64String(ds.Tables[6].Rows[1].ItemArray[2].ToString());
SaveToOut("image/jpeg", byt, true);
PerformScaleImage(contentType, content, Response, 150, 50);
MemoryStream stream = new MemoryStream();
stream.Write(buff, 0, buff.Length);
using (Bitmap img = new Bitmap(stream))/*---Giving invalid parameter exception-------*/
{
--------------------------}
}
Can you give details.
|
|
|
|
|
how to view power point show inside a web browser control in an application form ?
i have a powerpoint link ( local file ) , i need to make something like this :
webBrowser1.Url = new Uri(@file://c:\whatever\yourpresentation.ppt)
it doesn't work with me !!!
|
|
|
|
|
where are the experts
|
|
|
|
|
Hi friends,
how to validate textbox should accept only numeric in c#.Net. Please Help.
Thanks in Advance,
Regards,
Prya
|
|
|
|
|
You can override the OnKeyPress or OnValidating methods of the TextBox , if overriding the KeyPress then simply filter out the keystrokes which are not numeric. If overriding the OnValidating method then you can use int.TryParse to check to see if it's a valid integer.
There are numerous articles on the web about how to do this, the best solution in my opinion would be to override the OnKeyPress event.
I have no idea what I just said but my intentions were sincere.
Poore Design
|
|
|
|
|
That will work if the user didn't use the paste feature
|
|
|
|
|
Hadn't thought of that , suppose it'll have to be either the OnValidating or OnTextChanged .
I have no idea what I just said but my intentions were sincere.
Poore Design
|
|
|
|
|
|
to complete with a bit of code, what has been already so nicely said:
void TxtRegisteringKeyKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
char[] myNum = new char[11] { '0' , '1', '2', '3', '4', '5', '6', '7', '8', '9', '\b' };
bool blnNumFnd = false;
foreach (char c in myNum)
{
if (e.KeyChar == c)
blnNumFnd = true;
}
if (!blnNumFnd)
e.KeyChar = '\0';
}
|
|
|
|
|
Use MaskedTextBox Instead of Normal textbox, where you can restrict user entries
|
|
|
|
|
Hi,
I am having Text file that contains japanese characters ,I need to look out for Hiragana, Katakana and
ideograph characters searching through Microsoft and google i found that i can do it through Regular
Expressions
http://msdn2.microsoft.com/en-us/library/aa293063(VS.71).aspx[^]
I used Hiragana and Katakana regex like this string regexPattern = @"\p{IsHiragana}|\p{IsKatakana}"; its
working fine but for Ideograph I used \p{Lo} but this doesn't work
Any Help will be highly appreciated
Thanks and regards
Shweta Shrivastava
|
|
|
|
|
Hi
I am a computer engineer and I have developed some DLLs in .NET Framework 1.1 (C#.NET). Now I want to develop a new project in Visual C++ 6.0 and I need to use those DLLs in Visual C++. Would you please help me with this interoperability? I need a good and of course abstract resource in order to become familiar with these concepts and with the method I have to use for this transfer.
Thanks in advance
|
|
|
|
|
Tried Google[^]?
Surprise surprise where the first result it returned from...
I have no idea what I just said but my intentions were sincere.
Poore Design
|
|
|
|
|
hi,
In my windows application i added a menu strip item. The default color of the menu strip is the colors of the windows xp (blue and white).
When i change the backgroung color property to the color i want it is changed.
but when i click on an item for example File the menu that pops down under it has the color of the original menu strip (blue and white). I need it to be as the color i set. I couldn't find any property for that.
Is there a way to do it?
|
|
|
|
|
This code works for me.
MenuStrip mainmenu;
ToolStripMenuItem File;
ToolStripMenuItem News;
ToolStripMenuItem Exit;
mainmenu = new MenuStrip();
File = new ToolStripMenuItem();
News = new ToolStripMenuItem();
Exit = new ToolStripMenuItem();
mainmenu.BackColor = Color.Red;
mainmenu.ForeColor = Color.Yellow;
File.BackColor = Color.Violet;
File.ForeColor = Color.Cyan;
News.BackColor = Color.DarkBlue;
News.ForeColor = Color.DarkGreen;
Exit.BackColor = Color.DarkViolet;
Exit.ForeColor = Color.DeepPink;
File.Text = "File";
News.Text = "News";
Exit.Text = "Exit";
File.DropDownItems.Add(News);
File.DropDownItems.Add(Exit);
mainmenu.Items.Add(File);
this.Controls.Add(mainmenu);
|
|
|
|