我有一个表,我正在保存每个用户每个月的付款,最初我有一个名为month的列,但在为每个月保存几个付款后,它会变得过于聚集,所以我决定丢弃month列,并添加名为(1月、2月等一直到12月)的12列,现在我想在组合框中显示所有12列,这样我就可以选择1月并为该月付款。
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);
}
}有什么办法做到这一点吗?
发布于 2019-09-27 03:35:16
您可以简单地添加月份名称,直接从CultureInfo中读取它们
var months = CultureInfo.CurrentCulture
.DateTimeFormat.MonthNames.Select(x =>
CultureInfo.CurrentCulture.TextInfo.ToTitleCase(x)).ToArray();
odaberi_mjesec.Items.AddRange(months);https://stackoverflow.com/questions/58123262
复制相似问题