フォームには多くのリッチテキストボックスがあります。フォームがロードされるとき、私はrichTextBoxesをテキストファイルからのテキストで埋めたいと思う。各richTextBoxについては、私はテキストファイルを持っており、ファイルの名前はrichTextBoxの名前と同じです。 これを試しましたが、コンポーネントにロードファイル機能がないために動作しませんでしたか?すべてのrichTextBoxを取得し、同じ名前のテキストファイルをロードする
フォームを読み込むときに、どのように多くのファイルを別のリッチテキストボックスに読み込むことができますか?
private void getAllRichTextboxen(string aFileName)
{
foreach(Control item in this.Controls)
{
if (item is GroupBox) //first get the groupboxes, all the richTextBoxes are within a groupBox
{
foreach (Control aControl in item.Controls)
{
if (aControl is RichTextBox) //check if it is a richTextBox
{
if (aControl.Name == aFileName) //if the controle name = the same as the file name then load the file into the RichTextBox
{
aControl.LoadFile(Settings.applicatiePad + Form_Main.QueryMap + "\\" + aFileName + ".agq", RichTextBoxStreamType.PlainText));
//richTextBox1.LoadFile(openFile1.FileName, RichTextBoxStreamType.PlainText);
}
}
}
}
}
}