private void tPrefix_Validating( object sender, CancelEventArgs e )
{
if ( selectedRank == null )
return;
tPrefix.Text = tPrefix.Text.Trim();
if ( tPrefix.Text.Length > 0 && !Rank.IsValidPrefix( tPrefix.Text ) ) {
MessageBox.Show( "Invalid prefix character!\n" +
"Prefixes may only contain characters that are allowed in chat (except space).", "Warning" );
tPrefix.ForeColor = System.Drawing.Color.Red;
e.Cancel = true;
} else {
tPrefix.ForeColor = SystemColors.ControlText;
}
if ( selectedRank.Prefix == tPrefix.Text )
return;
string oldName = MainForm.ToComboBoxOption( selectedRank );
// To avoid DataErrors in World tab's DataGridView while renaming a rank,
// the new name is first added to the list of options (without removing the old name)
rankNameList.Insert( selectedRank.Index + 1, String.Format( "{0,1}{1}", tPrefix.Text, selectedRank.Name ) );
selectedRank.Prefix = tPrefix.Text;
// Remove the old name from the list of options
rankNameList.Remove( oldName );
Worlds.ResetBindings();
RebuildRankList();
}