I'm trying to represent the right double value in my Listbox. The values in my SQL Database are represented as "0,09" for example. Now I put these values which are in a certain column into a Listbox with a "SELECT DISTINCT" statement. When searching in the database I need to write "0.09" since "0,09" to find the value. That's not the problem. I tried to convert every single double value with
CultureInfo culInfo = new CultureInfo("en-US");
for (int i = 0; i < convertCol.Count; i++)
{
storeDouble = convertCol[i];
convertToString = storeDouble.ToString("0.######");
if (convertToString.Contains(","))
{
convertedString = convertToString.Replace(",", ".");
convertBackToDouble = double.Parse(convertedString, culInfo);
//Convert.ToDouble(convertedString);
convertedCol.Add(convertBackToDouble);
}
else
{
convertedCol.Add(convertCol[i]);
}
}
DataColumn dc = new DataColumn(form1.getColName());
dc.DataType = typeof(double);
datTable.Columns.Add(dc);
for (int j = 0; j < convertedCol.Count; j++)
{
datTable.Rows.Add(convertedCol[j]);
}
form1.colStorList.DisplayMember = form1.getColName();
form1.colStorList.ValueMember = "Column";
form1.colStorList.DataSource = datTable;
When I leave the cultureInfo out and try "Convert.ToDouble" then "0,09" gets converted to "9.0". With the cultureInfo it seems right but my Listbox has still entries like "0,09". How to "force" the ListBox to display my values as "0.09" ?