我有'对话框中的其他组件。形式,这个组合框。我想声明它的数据源或其项目列表与我在设计中创建的先前组合框相同,并且我从文件中加载了它的数据。我是怎么做到的?
public partial class CardBuilder : Form
{
public CardBuilder()
{
InitializeComponent();
private static class A
{
private static string ShowDialog(string T, string C, int AT)
{
int WX = system.Windows.Forms.SystemInformation.WorkingArea.Width,
WY = system.Windows.Forms.SystemInformation.WorkingArea.Height;
string AbilityResult = "";
Form dialog = new Form
{
Font = new System.Drawing.Font("Garamond", 15,
System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Pixel, ((byte)(0))),
FormBorderStyle = FormBorderStyle.Fixed3D,
Text = C,
StartPosition = FormStartPosition.Manual,
Location = new Point(WY - WY / 4, (WX - 350) / 2),
AutoSize = false,
SizeGripStyle = SizeGripStyle.Hide,
Owner = CardBuilder.ActiveForm,
ShowIcon = false,
ControlBox = false,
TopMost = true,
Width = 350,
Height = 140
};
ComboBox CT = new ComboBox()
{
DataSource = ??
Sorted = true
};
return Result;
}
}
答案 0 :(得分:0)
这是解决方案,因此您可以将其标记为已回答:)
private static class A
{
private static string ShowDialog(string T, string C, int AT, ComboBox copyFrom)
{
int WX = system.Windows.Forms.SystemInformation.WorkingArea.Width,
WY = system.Windows.Forms.SystemInformation.WorkingArea.Height;
string AbilityResult = "";
Form dialog = new Form
{
Font = new System.Drawing.Font("Garamond", 15,
System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Pixel, ((byte)(0))),
FormBorderStyle = FormBorderStyle.Fixed3D,
Text = C,
StartPosition = FormStartPosition.Manual,
Location = new Point(WY - WY / 4, (WX - 350) / 2),
AutoSize = false,
SizeGripStyle = SizeGripStyle.Hide,
Owner = CardBuilder.ActiveForm,
ShowIcon = false,
ControlBox = false,
TopMost = true,
Width = 350,
Height = 140
};
ComboBox CT = new ComboBox()
{
DataSource = copyFrom.DataSource,
Sorted = true
};
return Result;
}
}