Months combo box
unknown
csharp
2 years ago
1.7 kB
14
Indexable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
List<string> ListOfMonths = new List<string>()
{
"Gennaio",
"Febbraio",
"Marzo",
"Aprile",
"Maggio",
"Giugno",
"Luglio",
"Agosto",
"Settembre",
"Ottobre",
"Novembre",
"Dicembre"
};
foreach(var month in ListOfMonths)
{
cmb1.Items.Add(month);
}
}
private void cmb1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
cmb2.Items.Clear();
string month = cmb1.SelectedItem.ToString();
int x = 1;
switch (month)
{
case "Gennaio":
while(x <= 31)
{
cmb2.Items.Add(x);
x++;
}
break;
// TODO add remaining months cases
}
}
}
}
Editor is loading...
Leave a Comment