gpt4 book ai didi

c# - 将 ComboBox 插入动态表

转载 作者:太空宇宙 更新时间:2023-11-03 15:47:01 25 4
gpt4 key购买 nike

我正在尝试在动态表中创建一个 ComboBox,但我不确定我在这里做错了什么。

        table1.RowGroups[0].Rows.Add(new TableRow());
currentRow = table1.RowGroups[0].Rows[1];

ComboBox cbox=new ComboBox();
System.Windows.Controls.ComboBoxItem cboxitem=new System.Windows.Controls.ComboBoxItem();
cboxitem.Content="stuff";
cbox.Items.Add(cboxitem);

currentRow.Cells.Add(new TableCell(cbox)); //Error 1 The best overloaded method match for 'System.Windows.Documents.TableCell.TableCell(System.Windows.Documents.Block)' has some invalid arguments
currentRow.Cells.Add(new NumericUpDown()));

一旦用户输入数据,我如何向表格中添加带有新组合框的新行?

最佳答案

如错误所述,不存在直接接受 UIElement 作为其参数的 TableCell 构造函数。您需要使用 BlockUIContainer 包装它:

currentRow.Cells.Add(new TableCell(new BlockUIContainer(cbox)));

关于c# - 将 ComboBox 插入动态表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27751745/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com