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
path: root/mcs
diff options
context:
space:
mode:
authorIvan Zlatev <ivan@ivanz.com>2009-08-09 16:19:59 +0400
committerIvan Zlatev <ivan@ivanz.com>2009-08-09 16:19:59 +0400
commit82b0da56e306a3f8ab8930761780071c1ad9a4ff (patch)
tree39d026c7208299ea089f8984780366e6d2dec248 /mcs
parent1ed5e1ad21879390f29b7a125d72b85ffc903e35 (diff)
2009-08-09 Ivan N. Zlatev <contact@i-nz.net>
* DataGridViewCell.cs: Handle null and DBNull values. svn path=/trunk/mcs/; revision=139616
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog4
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs10
2 files changed, 13 insertions, 1 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
index 4721c24fcee..9e9cce50653 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-09 Ivan N. Zlatev <contact@i-nz.net>
+
+ * DataGridViewCell.cs: Handle null and DBNull values.
+
2009-08-07 Rodrigo Kumpera <rkumpera@novell.com>
* ListBindingHelper.cs: Fix the 1.0 build by making this type available
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs
index 1aa7031cb93..60ad73477d2 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs
@@ -887,6 +887,11 @@ namespace System.Windows.Forms {
value = e.Value;
}
+ if (value == null || (cellStyle != null && value == cellStyle.DataSourceNullValue)) {
+ if (FormattedValueType == typeof (string))
+ return String.Empty;
+ }
+
if (FormattedValueType == typeof(string) && value is IFormattable && !String.IsNullOrEmpty (cellStyle.Format))
return ((IFormattable) value).ToString (cellStyle.Format, cellStyle.FormatProvider);
if (value != null && FormattedValueType.IsAssignableFrom (value.GetType()))
@@ -922,7 +927,10 @@ namespace System.Windows.Forms {
if (DataGridView != null && (RowIndex < 0 || RowIndex >= DataGridView.Rows.Count))
throw new ArgumentOutOfRangeException ("rowIndex", "Specified argument was out of the range of valid values.");
- if (DataProperty != null)
+ if (OwningRow != null && OwningRow.Index == DataGridView.NewRowIndex)
+ return DefaultNewRowValue;
+
+ if (DataProperty != null && OwningRow.DataBoundItem != null)
return DataProperty.GetValue (OwningRow.DataBoundItem);
if (valuex != null)