|
There are many things wrong here.
Convert.ToDouble will work and is preferable of
(double)somevalue but the best method is
double.TryParse or int.TryParse
Secondly you need to use
txtPayment.Text = payment.ToString(); and make sure payment is not null.
If you do want an integer, you need to indeed first cast the double to an integer and then that integer to a string (or use round and floor functions)
Why do you cast to double in these cases?
double interestRate = (double)udInterest.Value / 100;
double termOfLoan = (double)(udTerm.Value * 12);
What is this code for? Own project, a book, homework?
V.
|
|
|
|
|
Very minor, but...
V. wrote: make sure payment is not null
payment is a double (not double? ) so cannot be null
|
|
|
|
|
You're absolutely right.
V.
|
|
|
|
|
V. wrote: and is preferable
No it isn't.
V. wrote: the best method is
Not when a cast will do.
|
|
|
|
|
double.Parse is not equivalent to a double cast. One does a string-to-number conversion, the other does a number-to-number conversion. You can use Convert.ToDouble to do either, but I disagree that it's preferable for either scenario: use the mechanism that makes sense in context. A cast translates to a single IL opcode, not a whole method call, after all.
|
|
|
|
|
Hello!
It's been only a few weeks since I have started to learn WPF, and I came across some assignments that needed color changing in the images being generated. For this, I was able to use radio buttons and get away with it, but I am interested to find out about using colour pickers.
Any idea as to how? Please share with me. I would appreciate it if the app is really simple though, because I am just an enthusiastic beginner.
|
|
|
|
|
You mean something like this[^] one?
|
|
|
|
|
Yes, something like that, but much simpler, so that a beginner can grasp the idea behind it.....
|
|
|
|
|
I don't think you're going to get anything WPF based that's much simpler than that.
|
|
|
|
|
I have to agree with Pete on this one.
"I have a theory that the truth is never told during the nine-to-five hours. "
— Hunter S. Thompson
|
|
|
|
|
Look at the mouse move event on the colour picker control, that's where the 'magic' happens.
And ew, Sasha uses empty catch blocks? heh.
|
|
|
|
|
Hi,
I am using this to refer to the MdiParent:
BrowsePatientForm.MdiParent = this;
is it possible to to refer to specific form instead so it will be something like this:
BrowsePatientForm.MdiParent = frmMain;
|
|
|
|
|
jrahma wrote: is it possible to to refer to specific form instead
Yes it is.
|
|
|
|
|
but I am getting this when I try:
Error 13
|
|
|
|
|
You have to have an instance of frmMain before you can actually use it like this. You can't just give it a type name and hope that it knows how to handle this - what would happen, for example, if you have two instances of frmMain?
|
|
|
|
|
As Pete O'Hanlon has already said, you need to assign it an instance of your form.
Typically in an app, there would be only one MDI Form (although .NET allows you to have more than one). You instantiate it at the start of your program and hold a reference to the instance in a static field somewhere.
Alternatively, you can also make your MDI Form a Singelton.
|
|
|
|
|
So long as variable frmMain is the correct instance of the MDI child form, then yes, its ok.
|
|
|
|
|
|
Hi All,
Please help me to know what is the best controls for windows applications from this features:
* Performance.
* Support right to left languages.
such as telerik, infragistics,..etc
thanks all
|
|
|
|
|
For right to left languages, you can use standard MS controls.
All you need to do is configure the appropriate language in the OS e.g. here[^].
|
|
|
|
|
HI,
But the MS Controls specially grid, doesn't have a grouping, filtering, summarizing, export to excel features.
Are There Another Control?
|
|
|
|
|
|
They all have trial versions available. Rather than getting the opinion of someone else, who might have different criteria for judging these things, why not trial the different versions yourself, and pick the one that best fits your needs and price requirements?
|
|
|
|
|
HI,
I try a trial versions but most of them doesn't support r-t-l languages.
|
|
|
|
|