Autor Beitrag
Scofield2011
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55

Windows XP, Windows 7, Windows 8
C#, VBA, VB
BeitragVerfasst: Sa 07.05.11 19:48 
Hallo,

ich habe da eine Frage zu den Comboboxen:

Und zwar hätte ich gerne eine Combobox,in der der Text rechts bündig formatiert ist, so weit gibts kein Problem. Kann man ja mit "RightToLeft" prima einstellen.

Jetzt habe ich aber leider den Button und die Laufleiste auf der linken Seite.

Gibt es eine Möglichkeit die Laufleiste und den Button rechts zu haben und trotzdem den Inhalt rechts formatiert zu haben?

Vielen Dank schon einmal im Voraus für eure Antworten.

Scofield2011
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4796
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: So 08.05.11 10:05 
Hallo,

die Eigenschaft 'RightToLeft' ist für Sprachen gedacht, welche eine Leserichtung von Rechts nach Links haben (z.B. Arabisch oder Hebräisch) und nicht für rechtsbündige Formatierung.
Und daher wandern auch die Buttons nach rechts, wenn du diese Eigenschaft aktivierst.

Um Text rechtsbündig in einer ComboBox darzustellen, mußt du den Text selber zeichnen (lassen):
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
// im Konstruktor (oder im Designer)
comboBox.DrawMode = DrawMode.OwnerDrawFixed;
comboBox.DropDownStyle = ComboBoxStyle.DropDownList;

void comboBox_DrawItem(object sender, DrawItemEventArgs e)
{
    e.DrawBackground();

    string txt = "";
    if (e.Index >= 0)
        txt = comboBox.Items[e.Index].ToString();

    TextRenderer.DrawText(e.Graphics, txt, e.Font, e.Bounds, e.ForeColor, TextFormatFlags.Right);
    e.DrawFocusRectangle();
}
Scofield2011 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55

Windows XP, Windows 7, Windows 8
C#, VBA, VB
BeitragVerfasst: Mo 09.05.11 23:01 
Noch einmal Danke für die Hilfe.