|
float.Parse(str) method should also work. Perhaps you might have committed some small mistake here and there. For testing it, create a new Windows Form project and place a button1 on that. In the click event-handler, put the following code:
private void button1_Click(object sender, System.EventArgs e)
{
string str = "145.35";
float x = float.Parse(str);
MessageBox.Show(x.ToString());
}
It works properly and the MessageBox shows the correct value of float variable as "145.35". If you use x in some expression such as x = x*2, again it will use the correct value. In the debug mode, when you check the value of x, again it shows the correct value. So please ensure that you use the proper coding, otherwise there is nothing wrong in the method.
|
|
|
|
|
Hi!
Is there a way of making a string html compliant (i.e. replacing german umlauts with the appropriate hex code), without hardcoding each character's translation.
|
|
|
|
|
Check out System.Web.HttpServerUtility.HtmlEncode(string)
Hope this helps
|
|
|
|
|
Thanks a lot! That was exactly what I meant. Although I must say that HttpServerUtility is only usable from within an ASP.NET application, for normal Windows apps HttpUtility has to be used.
|
|
|
|
|
Thank you for spending time here
You know in Visual Studio, when you move an object around such as a textbox, the cursor is changed to an arrow with a rectangle (the rectangle's size is equal to the size of the textbox) to indicate the new location of the textbox when you release the button..
I can change the cursor shape and all, but how do i draw that custom rectangle?
please help me out.
Elapid For The Win
|
|
|
|
|
anyone?
Elapid For The Win
|
|
|
|
|
What do you mean "custom rectangle"? You mean around a control? The designer is responsible for drawing that feedback mechanism (the border + handles). As for how they do it, there is a bunch of stuff inside System.Drawing that helps.
|
|
|
|
|
Thank you Tom for your reply.
I mean when you move a control (i.e Textbox) the Cursor is changed to an arrow with a rectangle which would show users that if they release the mouse, then the textbox will be moved in the place of the rectangle.
What I don't know is how to draw a rectangle with the cursor
please help me out
Elapid For The Win
|
|
|
|
|
Actually, the cursor doesn't change at all. What happens is the MouseMove event, the mouse buttons are polled to see if one is held down. If so, then a box representing the size of the control is drawn on the form, under the cursor.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you Dave.
I got that done
Elapid For The Win
|
|
|
|
|
Hi
I have a custom property updating another custom properety the code is as follows
<br />
public enum CodePageType { None, Swift, ASCII, Trade };<br />
public string RegularExpP<br />
{<br />
get { return regularEx; }<br />
set { regularEx = value; }<br />
}<br />
[Category("Custom Properties")]<br />
[DefaultValue(false)]<br />
public CodePageType Validate<br />
{<br />
get <br />
{<br />
if (type == CodePageType.ASCII)<br />
{<br />
RegularExpP = "Exp1";<br />
}<br />
if (type == CodePageType.None)<br />
{<br />
RegularExpP = "Exp2";<br />
}<br />
return type;<br />
}<br />
set {type = value;}<br />
}<br />
Now when i select the validate property the RegExpP property is set in the UI but its not getting updated in the Form1.Designer.cs Page.But its getting updated only the second time, and this time it sets the previous value i selected hat could be the problem
Regards
Deepak.s
|
|
|
|
|
I am working on a windows app and having some trouble getting type information by just the name. I have to load a file that will have several different type names (Type.FullName). When I call Type.GetType(fullname), it is always returning null, even for types that I would assume it wouldn't like System.Windows.Forms.TextBox. The only way that I can get it to return a type is if it is a local assembly, put it in format of 'Fullname,AssemblyName'. If it is not a local assembly, then I have to put it in the format of 'AssemblyQualifiedName'. This is ok, but it kinda screws some of the useability of the app. Does any one know a way around this? I know that I can use just the full name of the type if I am doing straight from the assembly reference (Assembly.GetType(fullname)), but I would prefer it if I didn't have to have a reference to the assembly to get the type (even though the assembly will be loaded at this point anyways). Any ideas would be greatly appreciated?
|
|
|
|
|
Can I ask what you are attempting to do? Type information is somewhat non-human friendly just because it is designed to be that way. Why are you asking the user for a type which may or may not be in any loaded assembly? Maybe you should instead offer a list of loaded types with a filter?
|
|
|
|
|
nevermind, i just altered the file format to allow the assembly name as well.
|
|
|
|
|
Hi
I have created web application to upload files. When the client uploades the files, the files should be put on to my server in a specific folder. Can this be done only through FTP or is there any other way to do it? The client could be in different place(one country) and the server could be in different place(another country). Can you send me the code for this?
|
|
|
|
|
Hi
I want to save pdf/tiff/bmp/jpg file formats in database and retrieve the same from database. i am using SQL Server 2000. I have a Windows form where i need to view these files. Right now i am using picturebox control. Files are saved to database and retrieved from database on to picturebox. But with picture box i can view the tiff files and not the pdf. Is there any way to view both tiff files and pdf files? Can you send the coding for this?
|
|
|
|
|
Did you ever get any information on this. I am having the same issue.
|
|
|
|
|
Hey!
I am building a program that recives data från a serail port and then puts it on streams to other units in the program.
Its inportant that this happens with no delay!
I have thougt of using regular stream, but i saw someone usning MemoryStream? maby MemoryStream is a better choce?
I need to be abled to write to this streams to.
What ar the diffrence between MemoryStream and regular stream?
BestRegards
Jimmy
|
|
|
|
|
Hey!
I have a incoming stream on a Serail port, i want to show this in a RichTextBox.
I have seen that i can load RichTextBox with a stream but it only loads whats in the stream at that moment?
Is there an easy way to let teh stream update the RichTextBox? or do i need to take the data out of the stream and then append to RichTextBox manualy?
And one other thing! i have tested to append data to my RichTextBox from another thread, but this is not posible? do i realy have to use the thread that created the RichTextBox? I am using delegates it another class to add data to the RichTextBox in the main form, this means that it will be another thread that adds data to the RichTextBox.
Best Regards
Jimmy
|
|
|
|
|
Hi,
I'm trying to send files (*.bmp;*.doc;*.gif;*.htm;*.html;*.jpg;*.pdf;*.tif;*.xls;*.txt) directly to a printer which should convert it to .tif with GhostScript.
I tried it with GhostScript, the PrintDocument Class, with the Image Class and through the console, but nothing works or just works for some files. I have a solution for converting the picture files, the txt files and the pdf files with the above mentioned methods, but it's a bit slow and not fully to my satisfaction or 100% right.
Isn't there a solution with which I can send every file type directly to the printer, or convert them direcly in the programm?
I hope you can help me.
Sorry when my english is bad
|
|
|
|
|
I am drawing a report using data from database.. I use the GDI+ drawing libraries, system.drawing.dll
The site works on the following computers:
- Microsoft windows 2000 pro Netherlands;
- Microsoft windows 2000 server english;
When i try to use it on a laptop with Windows XP pro SP2 english i get the following error:
"ArgumentExeption:INVALID PARAMETER USED"
I have found out that the error only occurs when the code draws a string. The drawing of rectangles and such work perfectly.
An example of the code on which it crashes is:
<br />
int BlockDateWidth = 2 * 60; <br />
Graphics tmpGraphics = Graphics.FromImage(new Bitmap(1,1)); <br />
.. <br />
.. <br />
objGraphics.DrawString("Startdate", new Font("Arial", 10), Brushes.Black, new PointF( <br />
((BlockDateWidth / 2) - tmpGraphics.MeasureString("Startdate", new Font("Arial", 10), 50).Width) / 2, waMaxHeight - 10)); <br />
i am trying to figure out why it works on 2000 server dutch and english and why it doesn't on that XP and 2003 server machine...
|
|
|
|
|
|
Invalid parameter used.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Invalid parameter used.
Source Error:
Line 270: objGraphics.DrawLine(new Pen(Brushes.Black, 1), BlockDateWidth, 0, BlockDateWidth, waMaxHeight + 10);
Line 271: //Date labels
Line 272: objGraphics.DrawString("Startdate", new Font("Arial", 10), Brushes.Black, new PointF(((BlockDateWidth / 2) - tmpGraphics.MeasureString("Startdate", new Font("Arial", 10), 50).Width) / 2, waMaxHeight - 10));
Line 273: objGraphics.DrawString("Enddate", new Font("Arial", 10), Brushes.Black, new PointF((BlockDateWidth / 2) + ((BlockDateWidth / 2) - tmpGraphics.MeasureString("Startdate", new Font("Arial", 10), 50).Width) / 2, waMaxHeight - 10));
Line 274: //Workareaname and dividing lines
Source File: c:\data\apmis\src\web\chart\milestoneplan.aspx.cs Line: 272
--------------
Thats the problem i get, i increased the height and width but didnt seem to work...
im trying to work on it..
|
|
|
|
|
another thing i wonder about is why it does work if i fade out all DrawString commands and it crashes when i dont... the strings that are being drawn lie within the image borders.
|
|
|
|
|
It appears that the following setting prohibits / fails using the DrawString() command of the graphics object.
objGraphics.CompositingMode = SourceCopy;
it looks like the the SourceOver option works i dont know if it is the combination of settings that i have used:
<code>
objGraphics.SmoothingMode = SmoothingMode.Default;
objGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
objGraphics.CompositingMode = CompositingMode.SourceOver;
objGraphics.CompositingQuality = CompositingQuality.GammaCorrected;
objGraphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
</code>
if i had used
<code>SourceCopy</code>
then i get the "INVALID PARAMETER USED" error.
anyway, it works now, if anyone has insight in the real reasons for this to happen, like why <code>Graphics.DrawString</code> can't be used together with
<code>Graphics.CompositingMode.SourceCopy</code>
im glad it works now :->
|
|
|
|