string
を使用してfromform SettingsMenu
をメインフォームに送信しようとしていますDelegate
。構造は次のとおりです。
SettingsMenuフォームで委任します。
delegate void ClocknameReceivedEventHandler(object sender, SettingsMenu.ClocknameReceivedEventArgs e);
SettingsMenuクラス内の内部クラスClocknameReceivedEventArgs:
public partial class SettingsMenu : Form
{
internal class ClocknameReceivedEventArgs : EventArgs
{
string _clockname;
public string Clockname
{
get { return _clockname; }
}
public ClocknameReceivedEventArgs(string clockname)
{
_clockname = clockname;
}
}
}
そして、コードのもう少し下にSettingsMenu
:
public event ClocknameReceivedEventHandler ClocknameReceived;
// Invoke the Changed event; called whenever list changes
protected void OnClocknameReceived(SettingsMenu.ClocknameReceivedEventArgs e)
{
ClocknameReceived(this, e);
}
私は以下を使用してSettingsMenu
から入ってくるデータをキャッチします:Main form
Event
_settings.ClocknameReceived += new ClocknameReceivedEventHandler(ClockClocknameReceived);
SettingsMenuから実際に文字列を受け取ったメインフォームのメソッド:
private void ClockClocknameReceived(object sender, SettingsMenu.ClocknameReceivedEventArgs e)
{
string ClockName;
ClockName = e.Clockname;
lblClockname.Text = ClockName;
}
これで、SettingsMenuクラスで次のエラーが発生します。
Error 2 Inconsistent accessibility: parameter type 'LivePigeonClient.Forms.SettingsMenu.ClocknameReceivedEventArgs' is less accessible than method 'LivePigeonClient.Forms.SettingsMenu.OnClocknameReceived(LivePigeonClient.Forms.SettingsMenu.ClocknameReceivedEventArgs)' D:\SVN\sentul\Livepigeonflights\trunk\LivePigeonClientSolution\LivePigeonClient\Forms\SettingsMenu.cs 54 24 LivePigeonClient
と
Error 1 Inconsistent accessibility: field type 'LivePigeonClient.Forms.ClocknameReceivedEventHandler' is less accessible than field 'LivePigeonClient.Forms.SettingsMenu.ClocknameReceived' D:\SVN\sentul\Livepigeonflights\trunk\LivePigeonClientSolution\LivePigeonClient\Forms\SettingsMenu.cs 51 52 LivePigeonClient
誰かが私が間違ったことを教えてもらえますか?