Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
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 wrap: on
line diff
--- a/FrmUnit.cs Mon May 31 19:05:01 2010 +0000 +++ b/FrmUnit.cs Mon May 31 19:44:23 2010 +0000 @@ -159,19 +159,35 @@ { StatSlot stat = statsWithName[i]; string slotName = stat.Name; + statsGrid.Columns.Add(CreateStatColumn(slotName, columnWidth)); dt.Columns.Add(CreateDataColumn(slotName)); - DataGridViewColumn col = statsGrid.Columns[i]; - col.Width = columnWidth; - col.CellTemplate = new StatsDataGridViewCell(); } - DataGridViewColumn nameColumn = statsGrid.Columns[0]; - nameColumn.Name = Translation.GetTranslation("UnitName", "Name"); - nameColumn.Width = statsGrid.Width - (statsCount * columnWidth); + int otherStatsWidth = statsCount * columnWidth; + SetNameColumnWidth(statsGrid, otherStatsWidth); return statsGrid; } + private static DataGridViewColumn CreateStatColumn(string slotName, int columnWidth) + { + DataGridViewColumn col = new DataGridViewTextBoxColumn(); + col.Width = columnWidth; + col.Name = slotName; + col.HeaderText = slotName; + col.DataPropertyName = slotName; + col.CellTemplate = new StatsDataGridViewCell(); + return col; + } + + private static void SetNameColumnWidth(DataGridView statsGrid, int otherStatsWidth) + { + + DataGridViewColumn nameColumn = statsGrid.Columns[0]; + nameColumn.HeaderText = Translation.GetTranslation("StatLineName", "name"); + nameColumn.Width = statsGrid.Width - otherStatsWidth; + } + private static DataColumn CreateDataColumn(string slotName) { log.DebugFormat("Create column {0}", slotName);
--- a/translations/en.translation Mon May 31 19:05:01 2010 +0000 +++ b/translations/en.translation Mon May 31 19:44:23 2010 +0000 @@ -64,6 +64,7 @@ <translation id="lblThanks">Thanks to:</translation> <translation id="FrmUnit">{0} ({1})</translation> <translation id="lblUnitSize">Unit size:</translation> + <translation id="StatLineName">Type Name</translation> <translation id="lblEquip">Equipment:</translation> <translation id="bttnAddWeapon">Add</translation> <translation id="lblAbilities">Abilities:</translation>