changeset 157:08271d6569fa

Fixes #287: New DataGridView crashes FrmUnit under Mono * Make sure that columns are explicitly defined and not implicitly created * Add proper stat line name column translation
author IBBoard <dev@ibboard.co.uk>
date Mon, 31 May 2010 19:44:23 +0000
parents d3f498514122
children 0ae6aff8c862
files FrmUnit.cs translations/en.translation
diffstat 2 files changed, 23 insertions(+), 6 deletions(-) [+]
line diff
     1.1 --- a/FrmUnit.cs	Mon May 31 19:05:01 2010 +0000
     1.2 +++ b/FrmUnit.cs	Mon May 31 19:44:23 2010 +0000
     1.3 @@ -159,19 +159,35 @@
     1.4  			{
     1.5  				StatSlot stat = statsWithName[i];
     1.6  				string slotName = stat.Name;
     1.7 +				statsGrid.Columns.Add(CreateStatColumn(slotName, columnWidth));
     1.8  				dt.Columns.Add(CreateDataColumn(slotName));
     1.9 -				DataGridViewColumn col = statsGrid.Columns[i];
    1.10 -				col.Width = columnWidth;
    1.11 -				col.CellTemplate = new StatsDataGridViewCell();
    1.12  			}
    1.13  
    1.14 -			DataGridViewColumn nameColumn = statsGrid.Columns[0];
    1.15 -			nameColumn.Name = Translation.GetTranslation("UnitName", "Name");
    1.16 -			nameColumn.Width = statsGrid.Width - (statsCount * columnWidth);
    1.17 +			int otherStatsWidth = statsCount * columnWidth;
    1.18 +			SetNameColumnWidth(statsGrid, otherStatsWidth);
    1.19  			
    1.20  			return statsGrid;
    1.21  		}
    1.22  
    1.23 +		private static DataGridViewColumn CreateStatColumn(string slotName, int columnWidth)
    1.24 +		{
    1.25 +			DataGridViewColumn col = new DataGridViewTextBoxColumn();
    1.26 +			col.Width = columnWidth;
    1.27 +			col.Name = slotName;
    1.28 +			col.HeaderText = slotName;
    1.29 +			col.DataPropertyName = slotName;
    1.30 +			col.CellTemplate = new StatsDataGridViewCell();
    1.31 +			return col;
    1.32 +		}
    1.33 +
    1.34 +		private static void SetNameColumnWidth(DataGridView statsGrid, int otherStatsWidth)
    1.35 +		{
    1.36 +
    1.37 +			DataGridViewColumn nameColumn = statsGrid.Columns[0];
    1.38 +			nameColumn.HeaderText = Translation.GetTranslation("StatLineName", "name");
    1.39 +			nameColumn.Width = statsGrid.Width - otherStatsWidth;
    1.40 +		}
    1.41 +
    1.42  		private static DataColumn CreateDataColumn(string slotName)
    1.43  		{
    1.44  			log.DebugFormat("Create column {0}", slotName);
     2.1 --- a/translations/en.translation	Mon May 31 19:05:01 2010 +0000
     2.2 +++ b/translations/en.translation	Mon May 31 19:44:23 2010 +0000
     2.3 @@ -64,6 +64,7 @@
     2.4  	<translation id="lblThanks">Thanks to:</translation>
     2.5  	<translation id="FrmUnit">{0} ({1})</translation>
     2.6  	<translation id="lblUnitSize">Unit size:</translation>
     2.7 +	<translation id="StatLineName">Type Name</translation>
     2.8  	<translation id="lblEquip">Equipment:</translation>
     2.9  	<translation id="bttnAddWeapon">Add</translation>
    2.10  	<translation id="lblAbilities">Abilities:</translation>