protected static ColumnHeader GetColumnHeader( string name )
{
ColumnHeader ch = new ColumnHeader();
StringBuilder sb = new StringBuilder();
sb.AppendFormat( "{0}_COLUMN", name );
// Part = Name;Text;Width;Align
// Example = From;From;80;Left
try
{
string[] parts = ResourceManager.GetString( sb.ToString().ToUpper( System.Threading.Thread.CurrentThread.CurrentCulture ),
"Workshare.Trace.UI.Properties.Resources",
typeof( BaseView ).Assembly ).Split( ';' );
if (parts.Length == 5)
{
ch.Name = parts[0];
ch.Text = parts[1];
int width = 60;
try
{
width = Int32.Parse(parts[2], System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat);
}
catch (FormatException)
{
// Assign a default value
}
ch.Width = width;
switch (parts[3])
{
case "Left":
ch.TextAlign = HorizontalAlignment.Left;
break;
case "Center":
ch.TextAlign = HorizontalAlignment.Center;
break;
case "Right":
ch.TextAlign = HorizontalAlignment.Right;
break;
}
ch.Tag = parts[4];
}
else
{
System.Diagnostics.Trace.WriteLine( "The column definitions was not valid in the resource table - " + name, "BaseView.GetColumnHeader" );
sb.Remove( 0, sb.Length );
string msg = ResourceManager.GetString( "COLUMN_INVALID",
"Workshare.Trace.UI.Properties.Resources",
typeof( BaseView ).Assembly );
sb.AppendFormat( msg, name );
if (ch != null)
ch.Dispose();
throw ( new ArgumentException( msg ) );
}
}
catch (NullReferenceException)
{
System.Diagnostics.Trace.WriteLine("The column name was not in the resource table - " + name, "BaseView.GetColumnHeader");
sb.Remove( 0, sb.Length );
string msg = ResourceManager.GetString( "COLUMN_INVALID",
"Workshare.Trace.UI.Properties.Resources",
typeof( BaseView ).Assembly );
sb.AppendFormat( msg, name );
throw ( new ArgumentException( msg ) );
}
return ch;
}