Merge pull request #111 from MihaelaStoica/CA-137470

CA-137470: Fixed unhandled exception raised by pressing space key on gri...
This commit is contained in:
Gabor Apati-Nagy 2014-07-04 14:11:36 +01:00
commit 077cf39366
4 changed files with 11 additions and 8 deletions

View File

@ -43,6 +43,7 @@ namespace XenAdmin.Controls.CheckableDataGridView
public class CheckableDataGridViewRowEventArgs : EventArgs
{
public int RowIndex { get; set; }
public bool RefreshGrid { get; set; }
}
/// <summary>
@ -340,11 +341,11 @@ namespace XenAdmin.Controls.CheckableDataGridView
}
[EditorBrowsable(EditorBrowsableState.Never)]
public void TriggerRowUpdatedEvent(int rowUpdated)
public void TriggerRowUpdatedEvent(int rowUpdated, bool refreshGrid)
{
RowUpdatedEvent handler = Events[RowUpdatedEventKey] as RowUpdatedEvent;
if (handler != null)
handler.Invoke(this, new CheckableDataGridViewRowEventArgs { RowIndex = rowUpdated });
handler.Invoke(this, new CheckableDataGridViewRowEventArgs { RowIndex = rowUpdated, RefreshGrid = refreshGrid });
}
[EditorBrowsable(EditorBrowsableState.Never)]

View File

@ -108,7 +108,7 @@ namespace XenAdmin.Controls.CheckableDataGridView
CheckableDataGridViewRow row = sender as CheckableDataGridViewRow;
if(row == null)
return;
UpdateRow(row);
UpdateRow(row, true);
}
public List<CheckableDataGridViewRow> CheckedRows
@ -122,7 +122,7 @@ namespace XenAdmin.Controls.CheckableDataGridView
return;
storedRows.ForEach(r=>r.Highlighted = false);
storedRows[rowIndex].Highlighted = true;
UpdateRow(storedRows[rowIndex]);
UpdateRow(storedRows[rowIndex], false);
View.DrawRowAsHighlighted(storedRows[rowIndex].Highlighted, rowIndex);
}
@ -188,7 +188,7 @@ namespace XenAdmin.Controls.CheckableDataGridView
/// Pass in the replacement row
/// </summary>
/// <param name="toUpdate">Replacement Row</param>
private void UpdateRow(CheckableDataGridViewRow toUpdate)
private void UpdateRow(CheckableDataGridViewRow toUpdate, bool refreshGrid)
{
if (toUpdate == null)
return;
@ -208,7 +208,7 @@ namespace XenAdmin.Controls.CheckableDataGridView
View.DrawUpdatedRow(storedRows[indexToUpdate].CellText, storedRows[indexToUpdate].CellDataLoaded,
storedRows[indexToUpdate].Disabled, indexToUpdate);
}
View.TriggerRowUpdatedEvent(indexToUpdate);
View.TriggerRowUpdatedEvent(indexToUpdate, refreshGrid);
}
private int ReplaceStoredRow(CheckableDataGridViewRow toUpdate)
@ -224,6 +224,7 @@ namespace XenAdmin.Controls.CheckableDataGridView
if (indexToUpdate >= storedRows.Count || indexToUpdate < 0)
{
log.DebugFormat("Unexpected index in ReplaceStoredRow row '{0}'; Stored rows contain '{1}' items", indexToUpdate, storedRows.Count);
return -1;
}
storedRows.Remove(storedRows[indexToUpdate]);
storedRows.Insert(indexToUpdate, toUpdate);

View File

@ -40,7 +40,7 @@ namespace XenAdmin.Controls.CheckableDataGridView
void DrawRowAsChecked(bool checkStatus, int rowIndex);
void DrawRowAsHighlighted(bool highlightStatus, int rowIndex);
void DrawRowAsDisabled(bool disabledStatus, int rowIndex);
void TriggerRowUpdatedEvent(int rowUpdated);
void TriggerRowUpdatedEvent(int rowUpdated, bool refreshGrid);
void TriggerRowCheckedEvent(int rowChecked);
void DrawUpdatedRow(Queue<object> textToUse, bool cellDataLoaded, bool rowDisabled, int rowIndex);
void DrawAllRowsAsCleared();

View File

@ -133,6 +133,7 @@ namespace XenAdmin.Dialogs
Controller.SummariseSelectedRow(checkableDataGridView.GetCheckableRow(e.RowIndex));
}
if (e.RefreshGrid)
senderGrid.SortAndRefresh();
}