|
Uhh, it's not a realy complicated solution but how about making two integers which contain the start window size and then after each resize (resize event) do like:
int SizeThingy = CurrentWidth - StartWidth;
CurrentHeight += SizeThingy;
and make the height CurrentHeight
the best solution i could think of (and the simplest one).
|
|
|
|
|
Save your form's aspect ratio (.Width /.Height , stored as a double ) in your form's Load event. Then in the SizeChanged event, compute and set the new height and width. If the SizeChanged event happens to be raised recursively, use a flag to ignore the event generated when your code modifies the form's dimensions.
/ravi
|
|
|
|
|
I can't seems to find enough sources to decode an attachment. I get the following line.
it tells me the name of the image and what type of content is it.
------=_NextPart_000_0010_01C74AC1.03E2B080
Content-Type: image/gif;
name="mapping.gif"
Content-ID: <001301c74ac1$03e2b080$0124cc3c@VALERIA>
Content-Transfer-Encoding: base64
Where i'm having problem is on the attachment that will look like this, how can i convert that?
<br />
<br />
<br />
R0lGODlhygHoAIcAAAAAAP/5lm/wAAmTOIIv8AAGb
4xgYGE1NTYKCgre3t+zs7CEhIVZWVouLi8DAwPX19SoqKl9fX5SUlMnJyf7+/jMzM2hoaJ2d<br />
<br />
------=_NextPart_000_0010_01C74AC1.03E2B080--<br />
<br />
|
|
|
|
|
As the content information tells you, it's base64 encoded. Take a look at the Convert.FromBase64String method.
---
single minded; short sighted; long gone;
|
|
|
|
|
thanks for the reply Guffa, i did a search on the Convert.FromBase64String and found a good source of code in http://msdn2.microsoft.com/en-us/library/system.convert.frombase64string(VS.71).aspx[^]
however when I run the following code I get the error Base 64 string length is not 4 or is not an even multiple of 4.
Did I miss something or Am I doing something wrong?
<br />
byte[] binaryData;<br />
try <br />
{<br />
binaryData = System.Convert.FromBase64String(attach);<br />
}<br />
catch (System.ArgumentNullException) <br />
{<br />
MessageBox.Show("Base 64 string is null.");<br />
return;<br />
}<br />
catch (System.FormatException) <br />
{<br />
MessageBox.Show("Base 64 string length is not " +<br />
"4 or is not an even multiple of 4." );<br />
return;<br />
}<br />
<br />
System.IO.FileStream outFile;<br />
try <br />
{<br />
outFile = new System.IO.FileStream(Application.StartupPath+"\\josetest.gif",<br />
System.IO.FileMode.Create,<br />
System.IO.FileAccess.Write);<br />
outFile.Write(binaryData, 0, binaryData.Length);<br />
outFile.Close();<br />
}<br />
catch (System.Exception exp) <br />
{<br />
System.Console.WriteLine("{0}", exp.Message);<br />
}<br />
|
|
|
|
|
What does the attach string contain? If you just ripped it from the mail, you have to remove the line breaks from it, so that it only contains the base64 data.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello everyone:
I have a TxtBox with vertibal bar enable and Button. When user click on Button and and browse to select any file, that file would get store on that txtbox.
I dont know how to started. Could someone please provide some sample code that I could work with?
Thanks,
Eyungwa
|
|
|
|
|
Did you not read my reply[^] to your earlier identical post?
/ravi
|
|
|
|
|
To let the user select a file take a look at the FileOpenDialog . An example how to use it is provided by its MSDN topic. How to load the file into a textbox was already answered in your other thread.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thank you Ravi,
tb_Text.Text = File.ReadAllText("C:\\Test");
I got this error saying " The name 'File' doesn't exist in the current context"
I like to have txtbox display all the files from C:\Test\ folder and being able to add any file onto that fold as well.
-- modified at 16:51 Wednesday 7th February, 2007
|
|
|
|
|
You need to add a reference to the System.IO namespace.
using System.IO;
/ravi
|
|
|
|
|
Hey guys,
I've got a form which contains a ToolStripContainer .
The container holds only tool strips.
In design mode, I can drag the tool strips and position them on a different ToolStripPanel , and organize them in any way I want.
However, when I run the application I can only drag and change the position of the tool strips within their original owning ToolStripPanel .
Is the ToolStripContainer class not designed to automatically enable dragging between panels?
I've looked forever for a built-in way to do that, and came up with nothing...
The only idea was to code it myself... Is this the way?
BTW, the form with the container is an MDI child.
Is this a problem?
Thanks in advance,
Shy.
|
|
|
|
|
I want to show only some collumns from a XML file.
I have 3 collums: IDName - Name - Age
I want that the datagrid show only Name
I tried:
dataGrid1.DataSource = ds.Tables[1].Columns["Name"];
but it doesn´t work... can you help me?
ThankS! dd
|
|
|
|
|
First, read the How to get answers post at the top. "Datagrid" is not a very discriptive subject.
You can create a single bound column in the datagrid.
Transform the XML before assigning it to the dataset.
only two letters away from being an asset
|
|
|
|
|
Will you please stop posting this question. You've asked the same question multiple times today.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
If one instance from my app is running I do not want another to run.
Thanks for help.
Dad
|
|
|
|
|
See these CP articles:/ravi
|
|
|
|
|
Hi,
I want to check if an item read from a database exists in the combobox before I add it to the combobox, so that the item is not repeated in the combox. For example I want to check for the reader["Area"] doesn't exist in "comboArea", if it doesn't exist, then add it to the combobox.
how can I translate that in C# language??
I'm not sure how it's written.
If anybody has anybody has any idea how to do this, plz send it.
|
|
|
|
|
Use a Hashtable to create a unique set representation of your data and store that in the ComboBox or just use myComboBox.Items.Contains() to check for an item's presence before adding it.
/ravi
|
|
|
|
|
thnx for the fast reply,
I used this function: myComboBox.Items.Contains()
but the problem is that it takes ListItem, and in my case I want to check reader["Area"] retrieved from a database, so it refuses this as an argument to the function..so is there any other way??
|
|
|
|
|
You may cast reader["Area"] to ListItem also you may add all fields while using reader, then filter the combobox on your own.
------------------------------ "The Soapbox has been so ..."
|
|
|
|
|
Nada Adel wrote: I used this function: myComboBox.Items.Contains()
but the problem is that it takes ListItem,
Huh?
Does this work? (Obviously I'm writing this out of context since I'm not familiar with your application, but hopefully you get what I mean).
myComboBox.Items.Clear();
foreach (Object o in objectsRetrievedFromDatabase) {
if (!myComboBox.Items.Contains (o)) {
myComboBox.Items.Add (o);
}
}
/ravi
|
|
|
|
|
thnx everybody
|
|
|
|
|
As an alternative to what people have said, is there any sort of pre-population of the items in the combobox? If you're just populating the CB from items in a database, and you don't want things to repeat, just use DISTINCT in the query from the database (I'm assuming SQL here), and just use the combobox.displaymember, combobox.valuemember, and combobox.datasource to set it up.
|
|
|
|
|
hi I've a c# windows application in which I'm not using Application.Run to open the initial form instead I'm using show method to open up the form. Now to the problem when I catch an exception after some processing I want to terminate the application but with Applicatin.exit(), I'm not able to do so. I read somewhere on the net that the form which started through Application.Run can only be terminated by Application.exit. Is there any other method.
Thanks in advance.
Don't Quit
|
|
|
|