我假定使用.Add()添加ListBoxItems或PageControls会完成默认设置,但是我的页面和列表框不会填充复选框。
//
public void InstantiateMyTabPage()
{
string rootPath = @"C:\Users\Director\Documents\TestCertApp";
//1@
string[] myDirs = Directory.GetDirectories(rootPath, "-",
SearchOption.TopDirectoryOnly);
foreach (string dir in myDirs)
{
//Here, I grab each dir in myDir in rootpath and make string wow = to that //string value at 1@
string wow = Path.GetDirectoryName(dir);
TabPage newPage = new TabPage();
newPage.Text = wow;
newPage.Name = wow;
tabControlFolders.TabPages.Add(wow);
//Just to test. Doesn't work either.
MessageBox.Show(wow);
}
}
//Skip listboxes
//CheckBoxes
public void InstantiateMyCheckBox()
{
string subFold =
@"C:\Users\Director\Documents\TestCertApp\TestSub";
var myFolders = Directory.GetFiles(subFold, " - ",
SearchOption.TopDirectoryOnly);
//for each certificate file create a check box named just the file name
foreach (string file in myFolders)
{
string wow2 = Path.GetFileNameWithoutExtension(file);
CheckBox thisBox = new CheckBox();
thisBox.Text = wow2;
thisBox.Name = wow2;
listColumn1.Items.Add(wow2);
//These do not show up in the listboxes I currently have.
}
}
预期通过调用加载页面,然后调用复选框填充列表框。 我有两个空的列表框和一个没有名称的标签页。