D
deko
I'm trying to create a class that will return a string based on a switch
statement that matches a control name.
The app in question has several forms, and I want to provide in-form help
based on which checkbox is checked. So, in the different form classes, the
code would look something like this (note this is vb-like pseudo code):
private void chkLogToDatabase_CheckedChanged(object sender, System.EventArgs
e)
{
if ( this.chkLogToDatabase.Checked == true )
{
this.chkLogToFile.Checked = false;
lblHelp = contextHelp(Me.Form.Name); // I want to call contextHelp,
passing to it the name of the form
lblHelp.Visible = True;
}
else
}
In the contextHelp class, I want to define the string that will be returned
to lblHelp:
using System;
namespace dsync.UI
{
/// <summary>
/// returns a string to be displayed in the calling form
/// </summary>
public class contextHelp
{
//loop through controls on form, find those that begin with chk and are
checked:
ctlName = ...
switch (ctlName)
{
case "chkLogToDatabase":
strLogHelp "Log to database message";
case "chkLogToFile":
strLogHelp = "Log to file message";
case "chkResetLog":
strLogHelp = "Reset Log message";
default:
strLogHelp = "Limit log size Message";
}
}
}
Any help is appreciated...
Thanks in advance.
statement that matches a control name.
The app in question has several forms, and I want to provide in-form help
based on which checkbox is checked. So, in the different form classes, the
code would look something like this (note this is vb-like pseudo code):
private void chkLogToDatabase_CheckedChanged(object sender, System.EventArgs
e)
{
if ( this.chkLogToDatabase.Checked == true )
{
this.chkLogToFile.Checked = false;
lblHelp = contextHelp(Me.Form.Name); // I want to call contextHelp,
passing to it the name of the form
lblHelp.Visible = True;
}
else
}
In the contextHelp class, I want to define the string that will be returned
to lblHelp:
using System;
namespace dsync.UI
{
/// <summary>
/// returns a string to be displayed in the calling form
/// </summary>
public class contextHelp
{
//loop through controls on form, find those that begin with chk and are
checked:
ctlName = ...
switch (ctlName)
{
case "chkLogToDatabase":
strLogHelp "Log to database message";
case "chkLogToFile":
strLogHelp = "Log to file message";
case "chkResetLog":
strLogHelp = "Reset Log message";
default:
strLogHelp = "Limit log size Message";
}
}
}
Any help is appreciated...
Thanks in advance.