|
Hello,
It seems that the condition for errorprovider is not set properly. Let me give you a very simple
example where we will display an errorprovider for a Textbox when alphanumeric values are entered.
<br />
Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged<br />
<br />
Dim num As Integer = 0<br />
<br />
If Not TextBox1.Text.Equals("") Then<br />
<br />
If Not IsNumeric(TextBox1.Text) Then<br />
<br />
ErrorProvider1.SetError(TextBox1, "Please enter numeric value")<br />
<br />
Else<br />
<br />
ErrorProvider1.Dispose()<br />
<br />
End If<br />
<br />
End If<br />
<br />
End Sub<br />
I hope this helps. In case the issue persists, just provide the code where you have implmented the
errorprovider.
Regards,
Allen
Allen Smith
Software Engineer
ComponentOne LLC
www.componentone.com
|
|
|
|
|
hy everyone!
does anyone of you know how to get the correct encoding of a textfile?
because i do read the file via a streamreader and write a new one with streamwriter. but sometimes i do have problems with some signs.
i know the file was created on a unix machine (line seperators just \n instead of \r\n in windows etc.).
streamreader and streamwriter allow encoding to be used as a second/additional parameter when reading or writing of/to the file.
so my two questions:
1) which encoding do i have to use for unix textfiles so the characters are read and written correctly? (because here in europe we have characters like "ö" or "ä" but they are not displayed correctly during writing the file. in the original file they are displayed correctly. so i want to provide the encoding in the parameter, but there are so many. and i am not sure, if i choose one which seems to be working on one file, does this mean it works for every unix textfile?
2) is there a chance to get the encoding of the file, when reading it without knowing it from the beginning? meaning, i want to find out the encoding when i access the file and set it when reading it, some kind of "dynamic encoding setting".
thanks.
stephan.
|
|
|
|
|
|
and which encoding type do i have to use? because i read the msdn but it confused me more than it helped. tons of different encoding specifications and descriptions
|
|
|
|
|
Sorry, I really don't know. Something unicode based is what you're looking for though I think. Personally I would say stop using *nix, but then i'm sure you have a good reason not too (otherwise i'll bash your head in with a really big book ).
|
|
|
|
|
Hi,
try new Encoding(codepage) where codepage probably is 1252.
There is no general way of detecting the encoding; if it is Unicode/UTF8 you
will find two special leading bytes; if it is an 8-bit ASCII extension (as I
expect it is for you), you won't get a clue: every codepage is another way
to map the top 128 byte values to a immense collection of possible characters.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hello everyone,
When we call Environment.Exit to terminates a console application or a Windows service,
1.
All the expected finally blocks are ensured to be executed, so resource leak?
2.
No exception occured (i.e. when invoking Environment.Exit, no exception thrown, like invoking Thread.Abort will throw ThreadAbortException?)
thanks in advance,
George
|
|
|
|
|
George_George wrote: All the expected finally blocks are ensured to be executed, so resource leak?
No, managed threads will be suspended and then terminated, so the CLR does not make any explicit attempt to execute finally blocks. It does execute finalizers though. And your process is going down, so the OS is going to cleanup all process local resources anyway.
George_George wrote: No exception occured (i.e. when invoking Environment.Exit, no exception thrown, like invoking Thread.Abort will throw ThreadAbortException?)
No again - it doesn't throw any exception as part of normal execution.
|
|
|
|
|
Cool, Senthil!
Question answered.
regards,
George
|
|
|
|
|
Please help!!
Can any one tell me how to extract Excel worksheet images and store them in database?
Thanks in advance.
|
|
|
|
|
Did you even try searching codeproject before asking this?
[^]
Loading an excel spreadsheet is trivial, as is putting the data into a database.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: Did you even try searching codeproject before asking this?
Did you read my question carefully before you reply?!!
I'm trying to read All images in an Excel file (not the spread sheet data)
and store these images in database.
Please don't reply if you have no idea.
|
|
|
|
|
Hi C# guyes,
hope, that somebody can help me. I tryed for some days now, to get my code working. But without luck. I can get the temp of my CPU out in a messagebox, but when i am trying to covert it to celcius from kalvin i get no results. I want the temp. in celcius out in a messagebox. How do i do that? Can somebody explain me how to? I will pass my code, thanks a lot
kennet
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Management;
namespace GetCpuTemp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ManagementClass processClass = new ManagementClass (@"root\WMI:MSAcpi_ThermalZoneTemperature");
foreach (ManagementObject service in processClass.GetInstances())
{
MessageBox.Show("CPU Temperature: " + service.GetPropertyValue("CurrentTemperature"));
}
}
static decimal ConvertToCelsius(string reading)
{
return (decimal.Parse(reading) / 10 - 273.15m);
}
}
}
modified on Sunday, April 27, 2008 7:52 AM
|
|
|
|
|
I though 1 Kelvin == 1 Celsius? Whats the /10 for?
You should also check what decimal.Parse actually returns, to make sure that parts working correctly.
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
(0 K = -273.15 °C and 273.16 K = 0.01 °C).[^]
Regards,
Thomas Stockwell
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.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Thomas Stockwell wrote: (0 K = -273.15 °C and 273.16 K = 0.01 °C).[^]
Yeah, so 1K = 1°C
Relative, not absolute.
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
Hi Thomas,
Thanks for your help,but I dont really understand it. I am just a beginner.
This code works properbly
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Management;
namespace GetCpuTemp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ManagementClass processClass = new ManagementClass(@"root\WMI:MSAcpi_ThermalZoneTemperature");
foreach (ManagementObject service in processClass.GetInstances())
{
MessageBox.Show("CPU Temperature: " + service.GetPropertyValue("CurrentTemperature"));
}
}
The messagebox show me a temp. of 3012 kelvin and my problem now is, that I like to convert it to celcius and read it out on a messagebox. Can you please help me, because I dont know how to do it. I tryed this code, but I dont know how to get it out in a massegebox.
static decimal ConvertToCelsius(string reading)
{
return (decimal.Parse(reading) / 10 - 273.15m);
}
Regards Kennet
|
|
|
|
|
kennet1974 wrote: I tryed this code, but I dont know how to get it out in a massegebox.
Really ? In that case, you are definately very much a beginner. You should buy a very basic C# book and work through it, instead of relying on these forums, you're not really ready to make this your main source of information.
Never call decimal.Parse, use TryParse so your code never blows up.
Two clues:
1 - every object in C# has a tostring method
2 - if you concatenate anything to a string, C# calls that for you, for free.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
All,
I have a requirement to find out where a particular process was started from (c:\somepath for example).
The system.diagnostics namespace doesnt appear to have this info, does anyone have any ideas?
Thanks,
|
|
|
|
|
It does have the info, but its a little hidden. What you need to look at is Process.MainModule.FileName .
So this would show you the paths for all the currently running processes:
foreach(Process proc in Process.GetProcesses())
{
MessageBox.Show(proc.MainModule.FileName);
}
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
|
Hello everyone,
I am new to this API. After some study, Application.Exit should only be used in Forms application, and in console/Windows service application without any GUI Window, we should not use it to exit application, right?
thanks in advance,
George
|
|
|
|
|
|
Cool, Urs!
I think the answer is, in console and Windows service application, Aplication.Exit has no use and it is not used to cause process to terminate, right?
regards,
George
|
|
|
|
|
Application.Exit will never terminate the process.
Normally you have something like this in your winforms app:
public void Main()
{
MyForm form = new MyForm();
Application.Run(form);
}
Application.Exit will cause that the Application.Run method returns to the Main method and then, of course, the process will end, because nothing is done afterwards.
best regards
Urs
-^-^-^-^-^-^-^-
no risk no funk
|
|
|
|