Static Method: FormResults.ChooseCharacters()
Returns: String
Declaration: ChooseCharacters(Form ParentForm, string DefaultValue = "", string FormTitle = "", string helpURL = "")

Example Choosing EOM Characters
A handy dialog for choosing ASCII character values which might not be printable and thus unsuited for a simple TextBox control. If passing in a DefaultValue it is just a regular string, the HEX conversion you see in Selected Characters above is done in the window code.
Example of a button click which calls the ChooseCharacters() method. Notice that the value is taken FROM a TextBox control (TXTEOM) where it is displayed to user in HEX then converted back into a plain string using the FromAsciiHexString() method of the COREUtilities object and then passed as the DefaultValue into ChooseCharacters(). When the call to ChooseCharacters() returns, the code verifies that the user DID NOT click cancel by checking the FormResults.FormCancelled property, and then converts the returned result BACK into HEX and repopulates the TextBox control with the resulting HEX value.
private void BTNSetEOM_Click(object sender, EventArgs e)
{
string x = MyUtilities.FromAsciiHexString(TXTEOM.Text);
string y = FormResults.ChooseCharacters(this, x, "Choose EOM Characters", HelpURL);
if (FormResults.FormCancelled) { return; }
if (string.IsNullOrEmpty(y)) { return; }
x = MyUtilities.ToAsciiHexString(y);
if (x != TXTEOM.Text)
{
TXTEOM.Text = x;
UpdateDisplay();
}
}
|