Vielen Dank schonma
Picturebox1image = Textbox1.text C#
#1 _Christopher_
geschrieben 23. Mai 2005 - 13:36
Vielen Dank schonma
Anzeige
#2
geschrieben 23. Mai 2005 - 13:53
you are running an OS
you use a Browser
I know so much about you...
#3
geschrieben 23. Mai 2005 - 13:55
#4
geschrieben 23. Mai 2005 - 13:57
Zitat (Witi: 23.05.2005, 14:55)
<{POST_SNAPBACK}>
Aha, naja die Untertitel sieht man nicht wenn man direkt von WF draufgeht.
you are running an OS
you use a Browser
I know so much about you...
#6
geschrieben 23. Mai 2005 - 14:02
hier mal eine Möglichkeit ohne Validierung der Eingabewerte:
if(this.textBox1.Text.Length == 6)
{
int r = Convert.ToInt32(this.textBox1.Text.Substring(0,2), 16);
int g = Convert.ToInt32(this.textBox1.Text.Substring(2,2), 16);
int b = Convert.ToInt32(this.textBox1.Text.Substring(4,2), 16);
this.pictureBox1.BackColor = System.Drawing.Color.FromArgb(r, g, b);
}
Evtl. geht es auch eleganter!?
#9
geschrieben 23. Mai 2005 - 14:13
Zitat (Christopher: 23.05.2005, 15:05)
Eigentlich meinte ich die Lösung.
Aber an deiner Schreibweise könntest du ruhig auch etwas "feilen"
#10 _Christopher_
geschrieben 23. Mai 2005 - 14:16
Noch was:
Wenn ich das anders rum will, das das der code von dem Image in der TextBox stehen soll...wie geht das
string r = this._color.Color.R.ToString();
string g = this._color.Color.G.ToString();
string b = this._color.Color.B.ToString();
this._code.Text = r + g + b;
Bitte nocheinma um Hilfe
#11
geschrieben 23. Mai 2005 - 14:16
Zitat (constructor: 23.05.2005, 15:02)
hier mal eine Möglichkeit ohne Validierung der Eingabewerte:
if(this.textBox1.Text.Length == 6)
{
int r = Convert.ToInt32(this.textBox1.Text.Substring(0,2), 16);
int g = Convert.ToInt32(this.textBox1.Text.Substring(2,2), 16);
int b = Convert.ToInt32(this.textBox1.Text.Substring(4,2), 16);
this.pictureBox1.BackColor = System.Drawing.Color.FromArgb(r, g, b);
}
Evtl. geht es auch eleganter!?
<{POST_SNAPBACK}>
das geht?!?!
müsste ToInt32 bei Buchstaben nicht eine FormatException auswerfen?
#13
geschrieben 23. Mai 2005 - 14:29
Zitat (Witi: 23.05.2005, 15:16)
Hab als Basis 16 angegeben - dann werden Hex-Werte akzeptiert.
public static int ToInt32(string value, int fromBase);
Allerdings fällt die Konvertierung auf die Nase, wenn ein Buchstabe > F oder ein anderes Zeichen eingegeben wurde *autsch*. Hier muss halt noch 'ne Validierung her - oder wenigstens ein Fehlerhandling.
#14 _Christopher_
geschrieben 23. Mai 2005 - 14:33
Zitat
string r = this._color.Color.R.ToString();
string g = this._color.Color.G.ToString();
string b = this._color.Color.B.ToString();
this._code.Text = r + g + b;
Bitte nocheinma um Hilfe
#15
geschrieben 23. Mai 2005 - 14:36
Zitat (constructor: 23.05.2005, 15:29)
public static int ToInt32(string value, int fromBase);
Allerdings fällt die Konvertierung auf die Nase, wenn ein Buchstabe > F oder ein anderes Zeichen eingegeben wurde *autsch*. Hier muss halt noch 'ne Validierung her - oder wenigstens ein Fehlerhandling.
<{POST_SNAPBACK}>
Achso...man lernt doch nie aus

Hilfe
Neues Thema
Antworten
Nach oben




