View previous topic :: View next topic |
Author |
Message |
kaikashu Master Cheater
Reputation: 0
Joined: 04 Apr 2007 Posts: 251 Location: Wait Let me check...
|
Posted: Tue Aug 21, 2007 11:45 am Post subject: C# Help |
|
|
My project is a C# Temp converter that changes Celsuis to Fahrenheit and Vice Versa.
My only problem is.. I have the buttons show the answer in a messagebox.
I want it to show in a ReadOnly Text box. Any Ideas?
Source code Here.
Code: | using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double temp = int.Parse(textBox1.Text);
double result = temp - 32.0 / 1.8;
MessageBox.Show(result.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
double temp = int.Parse(textBox1.Text);
double result = temp * 1.8 - 32;
MessageBox.Show(result.ToString());
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
foreach(char c in textBox1.Text)
{
if ((int)c < 48 || (int)c > 57)
{
MessageBox.Show("Invalid character");
textBox1.Text = "";
}
}
}
}
} |
And, I know I don't have the 2nd text box in my code yet so I'll add it when i get answers from you guys.
_________________
|
|
Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Tue Aug 21, 2007 12:03 pm Post subject: |
|
|
block all keys? :O
or try when its on focused then
focuse is false
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Aug 21, 2007 1:15 pm Post subject: |
|
|
textboxname.Text = Convert.ToString(variable);
|
|
Back to top |
|
 |
kaikashu Master Cheater
Reputation: 0
Joined: 04 Apr 2007 Posts: 251 Location: Wait Let me check...
|
Posted: Tue Aug 21, 2007 4:22 pm Post subject: |
|
|
Symbol wrote: | block all keys? :O
or try when its on focused then
focuse is false  |
Hmm Yes i know how to make it read only, i just don't know how to make the answer show up in a text box
_________________
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Aug 21, 2007 4:43 pm Post subject: |
|
|
slovach wrote: | textboxname.Text = Convert.ToString(variable); |
|
|
Back to top |
|
 |
|