Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorabrevet-dev <57099550+abrevet-dev@users.noreply.github.com>2019-12-02 19:39:43 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2019-12-02 19:39:43 +0300
commit1454b010ae1165a0f2cf261b9420e32d1b52fdaf (patch)
tree7ac2d46d5def736a4a6e97273ce360ee299d9d51 /mcs/class/System.Windows.Forms
parent865e955840cd7ec3d0eb4d32579109ce5f8c3869 (diff)
[WinForms] the Text property was not set for every cell in the column when UseColumnTextForLinkValue is true (#17981)
* [WinForms] Fix #17980 Prevent from crashing when DataGridView is null. Reproducer: DataGridViewLinkColumn links = new DataGridViewLinkColumn(); links.UseColumnTextForLinkValue = true; * [WinForms] Fix #17980 The field useColumnTextForLinkValue of DataGridViewLinkCell was not cloned. * [WinForms] Fix #17980 the Text property was not set for every cell in the column when UseColumnTextForLinkValue is true Fixes #17980
Diffstat (limited to 'mcs/class/System.Windows.Forms')
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridViewLinkCell.cs1
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridViewLinkColumn.cs29
2 files changed, 21 insertions, 9 deletions
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridViewLinkCell.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridViewLinkCell.cs
index 5ad53795577..904ab9ca7f8 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridViewLinkCell.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridViewLinkCell.cs
@@ -56,6 +56,7 @@ namespace System.Windows.Forms
clone.linkBehavior = this.linkBehavior;
clone.visited_link_color = this.visited_link_color;
clone.trackVisitedState = this.trackVisitedState;
+ clone.useColumnTextForLinkValue = this.useColumnTextForLinkValue;
return clone;
}
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridViewLinkColumn.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridViewLinkColumn.cs
index d5ef3cdd21f..2f98878ed92 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridViewLinkColumn.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/DataGridViewLinkColumn.cs
@@ -77,7 +77,8 @@ namespace System.Windows.Forms
throw new InvalidOperationException ("CellTemplate is null when getting this property.");
template.ActiveLinkColor = value;
-
+ if (DataGridView == null)
+ return;
foreach (DataGridViewRow row in DataGridView.Rows) {
DataGridViewLinkCell cell = row.Cells[Index] as DataGridViewLinkCell;
if (cell != null)
@@ -113,6 +114,8 @@ namespace System.Windows.Forms
throw new InvalidOperationException ("CellTemplate is null when getting this property.");
template.LinkBehavior = value;
+ if (DataGridView == null)
+ return;
foreach (DataGridViewRow row in DataGridView.Rows)
{
DataGridViewLinkCell cell = row.Cells[Index] as DataGridViewLinkCell;
@@ -137,6 +140,8 @@ namespace System.Windows.Forms
if (template == null)
throw new InvalidOperationException ("CellTemplate is null when getting this property.");
template.LinkColor = value;
+ if (DataGridView == null)
+ return;
foreach (DataGridViewRow row in DataGridView.Rows)
{
DataGridViewLinkCell cell = row.Cells[Index] as DataGridViewLinkCell;
@@ -150,20 +155,20 @@ namespace System.Windows.Forms
[DefaultValue ((string) null)]
public string Text {
get {
- DataGridViewLinkCell template = CellTemplate as DataGridViewLinkCell;
- if (template == null)
- throw new InvalidOperationException ("CellTemplate is null when getting this property.");
return text;
}
set {
if (this.Text == value)
return;
- DataGridViewLinkCell template = CellTemplate as DataGridViewLinkCell;
- if (template == null)
- throw new InvalidOperationException ("CellTemplate is null when getting this property.");
- //TODO : sets the Text property of every cell in the column
- //TODO only if UseColumnTextForLinkValue is true
text = value;
+ if (DataGridView == null)
+ return;
+ foreach (DataGridViewRow row in DataGridView.Rows)
+ {
+ DataGridViewLinkCell cell = row.Cells[Index] as DataGridViewLinkCell;
+ if (cell != null && cell.UseColumnTextForLinkValue)
+ cell.Value = value;
+ }
DataGridView.InvalidateColumn (Index);
}
}
@@ -184,6 +189,8 @@ namespace System.Windows.Forms
if (template == null)
throw new InvalidOperationException ("CellTemplate is null when getting this property.");
template.TrackVisitedState = value;
+ if (DataGridView == null)
+ return;
foreach (DataGridViewRow row in DataGridView.Rows)
{
DataGridViewLinkCell cell = row.Cells[Index] as DataGridViewLinkCell;
@@ -210,6 +217,8 @@ namespace System.Windows.Forms
if (template == null)
throw new InvalidOperationException ("CellTemplate is null when getting this property.");
template.UseColumnTextForLinkValue = value;
+ if (DataGridView == null)
+ return;
foreach (DataGridViewRow row in DataGridView.Rows)
{
DataGridViewLinkCell cell = row.Cells[Index] as DataGridViewLinkCell;
@@ -235,6 +244,8 @@ namespace System.Windows.Forms
if (template == null)
throw new InvalidOperationException ("CellTemplate is null when getting this property.");
template.VisitedLinkColor = value;
+ if (DataGridView == null)
+ return;
foreach (DataGridViewRow row in DataGridView.Rows)
{
DataGridViewLinkCell cell = row.Cells[Index] as DataGridViewLinkCell;