|
There is no class that will do this. Gathering the information you want is problematic at best.
I had to do the same thing, but not use .NET to do it. I ended up writing a class in VBScript that parsed the EDID data in the registry to get all of this information. The problem with that is the EDID data for every monitor to ever be attached to the machine is in there, and there is no way to find out which monitors are actually attached and which is the primary.
The data is under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY
What everything in that pile of data means can be found here[^].
My class supported data formats for all EDID versions up to and including 1.3.
No, I can't give it to you.
|
|
|
|
|
Monthly payment of $10000, the recruitment of Trojan horse to prepare the programmer
|
|
|
|
|
Hi,
I got the following error on server
Method not found: 'Void IBM.Data.DB2.DB2Connection.set_ParameterStreaming(Boolean)
It worked fine on my desktop with Visual Studio 2010.
I'm appreciate if someone can help.
Thanks,
|
|
|
|
|
Ask your question here[^].
|
|
|
|
|
Hello,
When i use below code - App launches and when entering values it loops two times through my if(tb != null) function - Any idea please?
And then somehow my total text box same value twice.
public Form()
{
InitializeComponent();
TextBox[] tbs = new TextBox[] { monTxtBox, tuesTxtBox, wedTxtBox, thurTxtBox, frdtxtBox };
foreach (var c in tbs)
c.TextChanged += new EventHandler(textBoxes_TextChanged);
}
private void textBoxes_TextChanged(object sender, EventArgs e)
{
TextBox tb = sender as TextBox;
if(tb != null)
{
decimal temp =0;
if(decimal.TryParse(tb.Text,out temp))
{
if(temp < 1)
totalTimetxtBox.Text = tb.Text+temp;
else
MessageBox.Show("Please enter the number between 0 and 1.");
}
else
MessageBox.Show("Please enter a decimal value only!");
}
}
|
|
|
|
|
shah123 wrote: it loops two times through
You mean like your requirement is that the value be between 0 and 1 so your event fires once for the "." and then fires again for the numerical value entered?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
yes somehow it fires 2 times - dont know why?
i just want to put 0.1 in one textbox,0.2 in 2nd textbox etc and then getting same time my totaltimetxtbox calculates as well
|
|
|
|
|
It does that because that is how you set it up to be. That event is going to fire every time you change the text in anyone of those textboxes. When you enter a "." it's going to fire, when you enter "1" it's going to fire, etc.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
so any solution to help pleas if possible?
|
|
|
|
|
That depends on your requirements. You could handle one of the other events of the TextBox, such as the Leave event, or LostFocus, or even the Validating event.
|
|
|
|
|
hello, thanks -
Iam trying to get the values of all textboxes and then adding it in totaltextbox but currently it takes only current textbox and when it leaves to 2nd it forgets the first one.
Any help please?
private void textBoxes_TextChanged(object sender, EventArgs e)
{
TextBox tb = sender as TextBox;
if (tb != null)
{
decimal temp = 0;
if (decimal.TryParse(tb.Text, out temp))
{
if (temp > 1)
MessageBox.Show("Please enter the nnumber between 0 and 1.");
}
}
}
private void textBoxes_Leave(object sender, System.EventArgs e)
{
decimal total = 0;
TextBox tb = sender as TextBox;
if (tb != null)
{
decimal temp = 0;
if (decimal.TryParse(tb.Text, out temp))
{
total += temp;
totalTimetxtBox.Text = total.ToString();
}
}
}
|
|
|
|
|
None of this code should be in the event handlers.
This stuff should be in its own method, called by the events handlers so you're not duplicating code all over the place.
Your addition code should be getting the values of all the textboxes it needs to and adding them together, not just the one where the focus left the textbox or had the textbox value changed.
It's "forgetting" the previous value because your total value is being reset to 0 every time the event handlers are called. Variables declared in a method only exist in that method and are destroyed when execution leaves the method.
|
|
|
|
|
Hi All,
I'm reading back some data from a board most of the time it gives it back correctly and I am displaying in a rich text box. On the odd occasion I get a blank line appearing not a problem! (the end user will not see it) the issue comes when I save the data out. I am
doing the following
Unit_Reply = Unit_Reply.Replace(" ", "");
to get rid of the spaces and
Unit_Reply = Unit_Reply.Replace("\r", "");
to get rid of stray carriage returns, the data is terminated by a \r\n and as this is being output I use the \n to get to a new line. Could there be an extra \r or \n or some other unprintable creeping in?
Glenn
|
|
|
|
|
glennPattonWork wrote: Could there be an extra \r or \n or some other unprintable creeping in?
Very possibly. You could always iterate over the data character by character to see what's in there. A simple test would be to write the index and ascii value of anything with an ascii value lower than the space character.
|
|
|
|
|
When you say iterate the data character, I'm using the ReadExisting() to get all the data coming in up to a New Line so if use lblIncomingData to show this (a label I already had invisible) for this purpose. I just need to convert to int? the value of the first character ( Convert.ToInt16(text) ) & run a simple int place counter right?
Glenn
|
|
|
|
|
Or, use a simple for loop like this:
for (int i = 0; i < myText.Length; i++)
{
if (myText[i] < ' ')
{
}
} It's that simple.
|
|
|
|
|
|
They all say that the first time.
|
|
|
|
|
Sorry it appears the rtb wasn't wide enough for the text!!
Sorry!!!
Glenn
|
|
|
|
|
I'm pretty sure he didn't mean that. That would be silly.
glennPattonWork wrote: I'm using the ReadExisting()
I would more likely use Read(Byte[], Int32, Int32) , but ReadExisting should be OK unless you find it isn't (in the past I've had trouble with some communication equipment inserting NULLs that weren't sent by the device).
Anyway, once you have the incoming string, you can iterate the characters:
e.g. foreach ( char c in s ) ...
and only pass along the ones you need. Personally I would write a class that would do all this and fire events for incoming strings/lines:
0) Instantiate a StringBuilder
1) Loop until told to stop:
1.1) Read incoming data
1.2) Iterate the incoming data
1.2.1) If printing character (or TAB), append to StringBuilder
1.2.2) If Carriage Return, Raise event to send contents of StringBuilder, clear StringBuilder
You may want to look at my TelnetSocket[^] for a similar technique (I thought I had a Serial Port version too).
|
|
|
|
|
I had more of a look the problem appears to be in the save command, but I will have a look at TelnetSocket.
Thanks
|
|
|
|
|
Okay I appear to have solved my problem in a silly way.
I just made the rich text box wider! Looking back into the code I was taking out all the stuff that could cause this kind of grief I just made the box too thin to take a long reading....(hangs head in shame!!! )
Thanks
Glenn
|
|
|
|
|
Do you mean that the text was wrapping?
|
|
|
|
|
I think so, I had made the box wide enough for the longest reading and tried to trim out all non-essential character,but it looks like that was the problem. Ah well testing time today!
Glenn
|
|
|
|
|
Well, that's cured that problem WordWrap to False.
|
|
|
|