|
Hello,
I have a string of the form 12.4454554, when I want to convert to float, one exception: the format of the input string is incorrect,
I use this :
float.Parse(my string);
how to convert my string to Float (two numbers after the comma)? thank you very much.
|
|
|
|
|
Here is only the quick'n'dirty version:
string tmp = "12.4454554";
tmp= tmp.Replace('.', ',');
double rounded= Math.Round(System.Convert.ToDouble(tmp), 2);
for a clean solution have a look on IFormatProvider.
[edit]
string tmp = "12.4454554";
double rounded= Math.Round(System.Convert.ToDouble(tmp,System.Globalization.CultureInfo.CreateSpecificCulture("en-us")), 2);
works too..
modified on Sunday, February 15, 2009 7:04 PM
|
|
|
|
|
Hi
i want to create a user control and add some other controls to it.
for example add a button to my userControl and let user to interact with this button at runTime (for example, allow user to click on it) and customzie it at designTime (for example, create event handler for click event), but when i drag userControl to my form, child controls did not have any interactivity behavior.
how to do that ?
thanks
modified on Sunday, February 15, 2009 5:55 PM
|
|
|
|
|
I tried the following, an it worked:
made a winform and placed a panel on it.
Than added a Button with somethink like this:
private void button1_Click(object sender, EventArgs e)
{
Button btn = new Button();
btn.Click += new EventHandler(btn_Click);
panel1.Controls.Add(btn);
}
void btn_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World");
}
Or did you mean someting different?
|
|
|
|
|
Hi Nico
i tried it also and my problem has been solved.
thanks
|
|
|
|
|
If you want to, for example, handle the click event of a button on a usercontrol, you should be handling it in the usercontrol code - nit in the form on which ou put the user control.
Similarly,if you want to design the button, you deign it in your user control.
If you want to be able to reuse your user control with, say, a different font on the button, then you need to add a property to your user control (lets call it ButtonFont) and write the Setter and Getter to access the Button's Font property.
If you REALLY want to access the button itself outside of the user control, at runtime e.g. you want code that says
MyUserControl1.OKButton.Text = "Hello";
then you need to set the Button's 'Modifiers' property in the user control to Public - so you can access it. This is not good practice, though, better to hide the button itself, and allow access only to those properties you want to give access to.
Similarly if you want to handle the click event of the button on the user control from within your form, you need to add an event to your user control - raise the event when the button is clicked. Thus the form doesn't know it was necessarily a button click event, just that the user control is telling it that some event has occurred.
For example - if your UC is used to select from a list of items, you might allow the user t double click on an item, selec the itme th click OK,select the item and press enter, click on a linklabel - etc. etc.
By raising a single event from the user control, the 'user' of tat control doesn't need to worry about what caused the event to fire - it just needs to know that it needs to handle the event because it has been raised.
Sorry for the rambling - this is a big subject & it depends on your requirements as to what you need to do for the best.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
|
I have a this case...
using System;
namespace FirstGenericClass
{
public classCounter
{
private int count;
public int Counter
{
get{ return count; }
}
public void Increament()
{
count++;
}
}
}
Here i want to write 2 classes, first one as a query class and the second one as a command class. How do I go about that
|
|
|
|
|
What do you want to query , and what do you want to command? So far all you have is an Int32 wrapper that has an increment method...
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
You write code. What was your question ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
If u nt gona answer the question, plz keep the f-up answers to yo self. A-hole
|
|
|
|
|
Member 3916856 wrote: the f-up answers to yo self. A-hole
Good way to alienate yourself. Good luck getting anyone to answer with an attitude like that.
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
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
I'm dearly sorry about my reply. But at time a person is just looking for an answer. You can just say when you not understanding the question
|
|
|
|
|
Hi AnyBody help me.....
In my project need a schedule a program with in a clock, so i decided to create
a clock circle and if drag and drop the some program in clock(Circle)that is added
to the particular clock time.so need idea to GUI design , if i drag a program to clock
that program duration only have different color ,like wise all program are displayed different color. And main important is if i need to changr or remove the program means
click that the color and drag and drop to the out sideof the circle, that program will removed from the circle . how can i do this give some idea.... I more expecting from you.
ThankYou
|
|
|
|
|
How are you going to determine the program's duration? Surely with a Task Scheduler you can only determine the start time?
Also, what are your plans if two programs coincide - there's no easy way in your plan to implement that.
A traditional clock face is 12 hours, but we have a 24 hour day - so there's another issue.
Not trying to discourage you, it could be an interesting approach, but it may need a little more time thinking about the concept.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thankyou for replay
The program duration already determined and that duration also maintain the database.
And clock issue was altered. Now we used every one an hour clock so that contain 60
minute. i will create 24 clock and that clock also assigned to the day grid.
Now what we want means The program are assigned to the clock(only for 60 minute).
For Example the programming(For Example consider song) duration is 10 minutes. and commercial break is 2 minutes. like wise fill an hour, if want to change the song means click the corresponding song then drag and drop out side of clock, the song
removed from the clock time that's only we want
Thankyou
|
|
|
|
|
i want 2 develop a client server architecture for DMS in education system in C# and database is SQL server so i want 2 provide a database on only server side n client can able 2 access dat database from client machine.....
plzzzzzzzz help meeeeeeeeee
|
|
|
|
|
Sounds good, with some effort it should work well. Don't forget to write an article to share with the community when you're done.
In the meantime, what specific part of your code is giving you trouble?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
OOh, and while I'm here...
madhuri pokharkar wrote: client server architecture for web appln in C#
That would be "application"
madhuri pokharkar wrote: i want 2
x 2: "I want to"
madhuri pokharkar wrote: dat
"that"
madhuri pokharkar wrote: plzzzzzzzz help meeeeeeeeee
"Please help me", and there's no need to say that. Everyone asking a question on these forums is wanting help, what would be the point in posting otherwise?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
OK. Permission granted. Please proceed.
Or did you have a more specific question about something your having a problem with?
|
|
|
|
|
Hi
I'm a 3rd year Software Development student, and for our 3rd year projects we need to create our own piece of software, which will be judged and marked throughout the year.
Our group decided on an interactive 3D environment. The main focus of our project is going to be furniture manufacturers. We want to allow them to use our program to model their own furniture, and customize them as well e.g. adjust the length and width of table legs, chairs, tables etc. We also want to integrate cost calculation, which must be dynamic, in other words the price must change as the user adjusts the dimensions.
I want to know, is this possible? Or should we start looking for other ideas.
Will users be able to work with pre-rendered models(created in TrueVision3D or any other 3D modeling application) and modify them to their liking?
Any help will be appreciated.
Thanks in advance
|
|
|
|
|
C# has access to Managed DirectX, so also Direct3D. Using it you can render almost everything. If there are classes that support TrueVision3D files I can't tell.. you might need to create them yourself or use a different file format.
Don't try it, just do it!
|
|
|
|
|
I'll be honest, 3D programming is something I haven't done before, so please be a bit more specific. What do you mean by 'access to managed DirectX & Direct3D'? How do one go about using those?
|
|
|
|
|
They are installed with the DirectX SDK. If you haven't done 3D programming before, then you might just be biting off more than you can chew with this project. It's not something that you can pick up quickly - 3D is one of the most demanding areas you can work in.
|
|
|
|
|
You may have a look at the XNA-Framework,
i think its a little bit easier then plain DX coding.
If you don't want to have so much trouble with 3D programming and your models are only a view simple sprites, then have a look at GDI+. I already saw some good "3d" charts with it.
|
|
|
|