TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ali G
NA
51
38.7k
On Text Changed in Textbox, Result Must Be Recalculated.
Dec 26 2012 3:06 AM
I am newbee. I am trying to make a unit converter. I have 2 textboxes and 2 listboxes.First textbox is for entry, second one is for result. Listboxes are for units.
I don't want any submit button. When I entering first textbox, the second textbox must show result on every changing in first textbox. OR listbox changings must change the result in the textbox2.
My very primitive codes are here. What are my mistakes?
CODE:
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;
namespace Conversion
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
{
listBox1.SelectionMode = SelectionMode.One;
listBox1.SetSelected(0, true);
listBox2.SelectionMode = SelectionMode.One;
listBox2.SetSelected(0, true);
Double DoubleSayi = Double.Parse(textBox1.Text);
Double DoubleKatsayi1 = 1;
Double DoubleKatsayi2 = 1;
Double DoubleSonuc = DoubleSayi*(DoubleKatsayi1 / DoubleKatsayi2);
textBox2.Text = DoubleSonuc.ToString();
switch (listBox1.SelectedItem.ToString())
{
case "kilometer": DoubleKatsayi1 = 1000; break;
case "hectometer": DoubleKatsayi1 = 100; break;
case "decameter": DoubleKatsayi1 = 10; break;
case "meter": DoubleKatsayi1 = 1; break;
case "decimeter": DoubleKatsayi1 = 0.1; break;
case "centimeter": DoubleKatsayi1 = 0.01; break;
case "milimeter": DoubleKatsayi1 = 0.001; break;
case "micrometer": DoubleKatsayi1 = 0.000001; break;
}
switch (listBox2.SelectedItem.ToString())
{
case "kilometer": DoubleKatsayi2 = 1000; break;
case "hectometer": DoubleKatsayi2 = 100; break;
case "decameter": DoubleKatsayi2 = 10; break;
case "meter": DoubleKatsayi2 = 1; break;
case "decimeter": DoubleKatsayi2 = 0.1; break;
case "centimeter": DoubleKatsayi2 = 0.01; break;
case "milimeter": DoubleKatsayi2 = 0.001; break;
case "micrometer": DoubleKatsayi2 = 0.000001; break;
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
END OF CODE
Reply
Answers (
1
)
From Date and To date for that validate code needs me
How to use outlook mail window for sending mail from C#