Autor Beitrag
lapadula
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 180
Erhaltene Danke: 10



BeitragVerfasst: Do 04.10.18 11:29 
Hallo,

ich versuche gerade Dezimalwerte (1.0, 1.1,..) in eine Combobox zu packen. Die ComboBox seperiert mir die Werte aber mit einem Komma. Wie kann ich das umstellen?

So gehe ich vor:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
List<decimal> mylist = new List<decimal>();
            for (int i = 1; i < 10; i++)
            {
                for (int x = 0; x < 10; x++)
                {
                    var stringValue = i.ToString() + "." + x.ToString();
                    var decimalValue = Convert.ToDecimal(stringValue, new CultureInfo("en-US"));
                    mylist.Add(decimalValue);
                }
            }
            myComboBox.DataSource = mylist;
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Do 04.10.18 16:01 
Die ComboBox (wie alle anderen Controls auch) verwendet die aktuelle CultureInfo zur Darstellung von Zahlenwerten (wahrscheinlich bei dir also "de-DE").

Entweder du gibst die Werte direkt als string an die ComboBox oder aber du änderst die CultureInfo für die gesamte Anwendung: Gewusst wie: Festlegen der Kultur und Benutzeroberflächenkultur für die Windows Forms-Lokalisierung.

Für diesen Beitrag haben gedankt: lapadula