我有一张表格,我在其中保存每个用户每个月支付的款项,最初我有一个列为month的列,但是在保存每个月的几笔付款之后,它会变得过于聚集,因此我决定放弃列month并添加12列(一月,二月等,一直到十二月),现在我想在组合框中显示所有12列,这样我就可以选择一月并为该月付款。
void FillCombo()
{
string constring = "server=localhost;user id=David;password=root;persistsecurityinfo=True;database=bazakudsumari";
string Query = "SELECT * FROM bazakudsumari.evidencija_clanarina;";
MySqlConnection connection = new MySqlConnection(constring);
MySqlCommand command = new MySqlCommand(Query, connection);
MySqlDataReader myReader;
try
{
connection.Open();
myReader = command.ExecuteReader();
while (myReader.Read())
{
string sSijecanj = myReader.GetString("sijecanj");
odaberi_mjesec.Items.Add(sSijecanj);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
有什么办法吗?
答案 0 :(得分:0)
您只需添加直接从您的CultureInfo读取月份的月份名称
var months = CultureInfo.CurrentCulture
.DateTimeFormat.MonthNames.Select(x =>
CultureInfo.CurrentCulture.TextInfo.ToTitleCase(x)).ToArray();
odaberi_mjesec.Items.AddRange(months);