私は C# プログラミングをあまりやったことがありません。私はC / C ++がとても得意です。プロジェクト内の他のクラスからクラス メンバーにアクセスする適切な方法がわかりません。たとえば、ユーザーが Channel クラスの情報を入力できるポップアップ ボックスである addChannel() クラスがあります。これらのチャネルを保持する treeView があります。treeView は、ツリーを含むメイン フォームである ListView クラスにあります。addChannel ポップアップ ウィンドウにボタンがあり、クリックすると、新しい Channel() が追加され、このチャネルが新しいノードとしてツリーに追加されます。ただし、ツリーにまったくアクセスできず、方法がわかりません。関連するコードを次に示します。
namespace RSSReader
{
public partial class addChannel : Form
{
public addChannel()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// Save the info to an XML doc
// I want to access the channelTree treeView here
this.Close();
}
}
}
そして、これがデザイナーの ListView 部分クラスです
namespace RSSReader
{
partial class ListView
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
// ALL THE INITIALIZATION IS HERE... I excluded it
public System.Windows.Forms.TreeView channelTree;
private System.Windows.Forms.WebBrowser webBrowser;
private System.Windows.Forms.Button addBtn;
private System.Windows.Forms.Button setBtn;
private System.Windows.Forms.Button remBtn;
private System.Windows.Forms.RadioButton titleFilter;
private System.Windows.Forms.RadioButton dateFilter;
}
}