|
Can anyone tell me why strSpd2 in the example below ends up being a
blank string when formatting a zero value? It would seem to me that
strSpd2 should end up being "0.0"
double val1 = 14.38009
double val2 = 0.0;
string strSpd1 = "";
string strSpd2 = "";
// This formats correctly. strSpd1 = "14.4"
strSpd1 = String.Format("{0:##.#}", val1);
// This does not format. strSpd2 = "" Why is this blank and not "0.0"
strSpd2 = String.Format("{0:#.#}", val2);
Craig
|
|
|
|
|
Yes, the # means "Put a digit here if it is significant". Since leading and trailing 0's are not significant, you are getting no value. Use, "{0: 0.0}" as your format specifier, as described here[^].
-Jeff
|
|
|
|
|
have a menu strip in my application with:
File Edit View Tool
Under my view heading I have a option to see end of line characters, what I want do is have it so the user knows when this has been clicked on, the problem is that I have an image in the TooStripMenuItem so you can't see the check mark when it is clicked. Any ideas?
|
|
|
|
|
Perhaps you could change...
1. The style of the menu item (ie, bold means active, normal means inactive)
2. The image associated with the menu item
3. The text for the menu item (Like "Show Newlines" vs. "Hide Newlines")
Hope this helps,
-Jeff
|
|
|
|
|
Hi all,
Here is my question. I have 3 forms,
FormMain
Form1
Form2
Form1 and Form2 are loaded into panels on FormMain. I need to access Form2 from Form1. Say I need to disable Form2 if a button is clicked on Form1 BUT I need to do it from Form1 (it is easy to control the instances from FormMain but that is not what I need).
Any suggestion?
Thanks!
-Kam
|
|
|
|
|
Naz wrote: I need to access Form2 from Form1. Say I need to disable Form2 if a button is clicked on Form1 BUT I need to do it from Form1
Pass form2 to the constructor of form 1 on load.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Ok, let me explain it again. Neither Form1 nor Form2 are aware of existence of one another. They are loaded in MainFrom. If I pass Form2 to the constructor, I suppose I need to create a new instance of the form. Then the instance in MainForm would be independent to this new instance and Form1.
Maybe I am not following you. Please explain more if you get a chance.
-K
|
|
|
|
|
If I understand you correctly, MainForm knows of the instances of Form1 and Form2. Have Form1 raise an event in MainForm that disables (or whatever other action) it's instance of Form2.
|
|
|
|
|
I see. Could you be able to write a few lines of code on how doing this? I am thinking of using delegates. I have already spent so much time on this and finally someone has an answer! Thanks a lot!
|
|
|
|
|
You're on the right track. Declare an event in Form1, a delegate and handler method in MainForm and you should be good.
|
|
|
|
|
A better bet for you would be to use a moderator class. The main form would create the mediator and the mediator would be responsible for managing your forms. As an example:
In FormMain:
private Mediator _mediator = new Mediator();
_mediator.CreateForm1();
_mediator.CreateForm2(); In the mediator class, the CreateFormn methods would be responsible for instantiating the forms. Obviously, the mediator would catch events from the forms and respond to them to manage the state as appropriate.
|
|
|
|
|
Pete O'Hanlon wrote: A better bet for you would be to use a moderator class. The main form would create the mediator and the mediator would be responsible for managing your forms. As an example:
In FormMain:
private Mediator _mediator = new Mediator();// Create an instance of Form1_mediator.CreateForm1();_mediator.CreateForm2();
In the mediator class, the CreateFormn methods would be responsible for instantiating the forms. Obviously, the mediator would catch events from the forms and respond to them to manage the state as appropriate.
I didn't even know that could be done. That would be the way to go. It seems to me like at least once every week I learn something from you Pete. Got my 5.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
No problem. I don't know who 1 voted you for that, so have yourself a 5 to balance things up a bit. (If your average moves above 3 then it's a relatively new CP user).
|
|
|
|
|
HI,
i've a problem :
App 1 stores from GUI Messages and then using a simple for
statmaent sends them to App2
App2 listen and gets the Messages into a buffer without knowing where
a Message begin or ends
is there a way to send a Message From App 1 to App 2
and wait until it is handeled in App2 and on...
until last Msg says "Finished"?
Any suggestions?
THANKS
Have Fun
Never forget it
|
|
|
|
|
App 2 should know the begin and end. TCP/IP is a guaranteed in order protocol. Use lengths and commands in your TCP/IP stream as a signal.
Also, MSMQ would probably be better for message passing.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
half-life wrote: is there a way to send a Message
Yes. It's called protocol[^]
|
|
|
|
|
Hi all,
would this work to enter days, mins, and hrs in the textboxes and taking extension from a combo box and when the button is pressed the files with specific extension get deleted.
[Code]
private void DeleteFiles_Click(object sender, EventArgs e)
{
FolderWatcher fw = new FolderWatcher();
fw.FolderPath = @"c:\csharp"; // FolderName
OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
fw.DeleteFilesOlderThan(int.Parse(Textbox1.Text), int.Parse(Textbox2.Text), int.Parse(Textbox3.Text), OpenFileDialog1.Filter); // deletes everything older than specified days,hrs, and mins respectively
}
[/Code]
|
|
|
|
|
Have you got this working yet?
|
|
|
|
|
Hi All,
I wonder if any one could help me!!!?
I want to Match 2 words with some different letters (ex. man and woman(should match), man and ran (should match)).
thanks .
|
|
|
|
|
private Boolean CompareStrings(String firstString, String secondString)
{
return true;
}
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
"someString".IndexOf("some") != -1
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
I have problem with Multiline TextBox. I have activex component with textbox on website. On this site i have too menu maked in css. When i show menu my textbox blinked. In textbox without multine option is ok.
|
|
|
|
|
how can i read the whole class information using C#?
means, i need All class name under a .cs file, there property, field, methods etc.
I have tired using Reflection ,But It will generate in runtime !!!! But i need designed time Just like Class Designer in .NET.
I am studing on DTE and Codemodel of VS.NET,
can you kindly help me do it !!!!
Any Idea !!! Any Reference !!!
Thanks in Advance !!!!!
|
|
|
|
|
If it is at design time, then why can't you just LOOK at the classes within a .cs file? Just import the namespace and use the classes. What exactly are you trying to do?
-Jeff
|
|
|
|
|
Skippums wrote: What exactly are you trying to do?
I want to draw UML diagram from a .cs file. Like Class Diagram. It will be a Addin in .net. Now I thing it is clear for your. So any suggestion for do it !!!!
Any kind of idea!!!!
Thanks in advance !!
|
|
|
|