Autor Beitrag
Hardstyler_88
Hält's aus hier
Beiträge: 1



BeitragVerfasst: So 18.01.09 19:38 
haai alle zusammen,

bin anfänger und brauche hilfe!!



möchte mit: textbox, lable, button, und 3x checkbox folgendes machen

also:

in textbox einen text eingeben, dann

checkbox1 = bold
checkbox2 = italic
checkbox3 = underline

auswählen, dann auf button drücken

und dann soll das ganze im lable erscheinen...

wie mach ich das???

ich hab schon sau viel probiert, hab aba imma nua fehler drin, bitte um schnelle antwort!!!



denke für euer bemühen im voraus!!


lg da hardstyler ^^


Zuletzt bearbeitet von Hardstyler_88 am So 18.01.09 19:54, insgesamt 1-mal bearbeitet
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 18.01.09 19:40 
Hallo,

bitte ändere den Titel des Topics, da er wenig über das eigentlich Thema verrät. Hier der entsprechende Absatz aus den Richtlinien:

1.2 Beiträge:
Bitte formuliere den Betreff Deiner Beiträge so, dass andere Mitglieder anhand dieser bereits das eigentliche Thema festmachen können. Beiträge wie etwa "Eine Anfängerfrage" oder "Weiß jemand, wie das geht?" lassen den Leser im Unklaren darüber, was das Thema der Diskussion ist.[...]


Einfach oben bei Deinem ersten Beitrag auf user defined image oder user defined image klicken und den Titel ändern. Danke Dir!

Viele Grüße,
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
miniC#
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 75

Wiin XP Home
C# VS Express 2008
BeitragVerfasst: Mo 19.01.09 13:57 
Hallo,

habe ich auch erst vor kurzem geleernt - es gibt FlagsAttribute enumerations. sie erlauben kombinationen aus der enumeration.

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
[FlagsAttribute] 
 enum Fahrzeuge
 {
     Auto = 0,
     Bus = 1,
     Bahn = 2
 };


(myFahrzeuge)0 ist natürlich auto, (myFahrzeuge)3 ist Bus & Bahn. fontstyle ist soeine enumeration.

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
private void UpadateLabel(Label Label)
{
   FontFamily fontfamily = Label.Font.FontFamily;
   FontStyle newstyle = FontStyle.Regular;

   if (CheckBoxBold.Checked & CheckBoxItalic.Checked) 
       newstyle = (FontStyle)3;
   else if (CheckBoxBold.Checked)
       newstyle = (FontStyle)1;
   else if (CheckBoxItalic.Checked)
       newstyle = (FontStyle)2;
   Label.Font = new Font(fontfamily, Label.Font.Size, newstyle);
}


Um evenetuell nötige Fehlerkorrektur wird gebeten, kann hier net im Compiler überprüfen, aber glaube Fonstyle ist :

ausblenden Quelltext
1:
2:
3:
4:
0 - Regular
1 - Bold
2 - Italic
...

_________________
Zitat MDSN : " ... C# (gesprochen: "si scharp") " :D
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Mo 19.01.09 17:24 
Da hast du aber ein paar Magic Constants reingebaut ;) . Für boolesche Ausdrücke benutzt man übrigens normalerweise immer "&&", egal ob man dessen "Shortcut-Feature" braucht oder nicht.
Enums lassen sich über "|" (OR) verknüpfen:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
FontStyle newstyle = FontStyle.Regular;
if (CheckBoxBold.Checked)
  newStyle |= FontStyle.Bold;
if (CheckBoxItalic.Checked)
  newStyle |= FontStyle.Italic;

_________________
>λ=