问题描述
感谢所有提供帮助的人。
我有一个正在VB中工作的WPF应用程序。 XAML具有一个DataGrid,并且在DataGridColumns内,并且具有DataGridColumns的DataGridComboBoxColumn带有下拉菜单。因此,组合框。当用户启动程序时,DataGrid如下所示。
除映射注释外,数据表中的每个字段均已下拉,并且希望/需要保存。
如您所见,用户可以从DatatableComboBox的下拉列表中进行选择。每当用户在下拉菜单中选择某些内容时,我都希望将其保存在应用程序中。下次我打开它时,我想重新加载先前从所选下拉菜单中保存的内容。
我在下面的示例中查看了另一个线程,但是无法编译
<Grid>
<Grid.RowDeFinitions>
<RowDeFinition Height = "28" />
< RowDeFinition Height="38" />
<RowDeFinition Height = "120" />
< RowDeFinition Height="120" />
</Grid.RowDeFinitions>
<ComboBox x:Name="comboBox2" Grid.Row="1" SelectionChanged="comboBox2_SelectionChanged" >
<ComboBoxItem x:Name="al" Content="Always" Tag="1"/>
<ComboBoxItem x:Name="wp" Content="While Playing" Tag="2"></ComboBoxItem>
<ComboBoxItem x:Name="ne" Content="Never" Tag="3" ></ComboBoxItem>
</ComboBox>
</Grid>
C#代码
public partial class comboBox : Window
{
public comboBox()
{
InitializeComponent();
}
private void Window_Loaded(object sender,RoutedEventArgs e)
{
//comboBox.Selectedindex = (int)Properties.Settings.Default["Username"];
comboBox2.Selectedindex = (int)Properties.Settings.Default.SelectIndex;
}
private void Window_Closed(object sender,EventArgs e)
{
}
private void comboBox2_SelectionChanged(object sender,SelectionChangedEventArgs e)
{
// ... Get the ComboBox.
var comboBox = sender as ComboBox;
Properties.Settings.Default.SelectIndex = comboBox.Selectedindex;
Properties.Settings.Default.Save();
}
}
请问能否在VB和XAML中帮助我,并帮助我保存所选字段?
非常感谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)