[Mono-bugs] [Bug 76770][Maj] New - DataGrid error
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Sun Nov 20 08:55:07 EST 2005
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by federico.giampietro at studifin.it.
http://bugzilla.ximian.com/show_bug.cgi?id=76770
--- shadow/76770 2005-11-20 08:55:07.000000000 -0500
+++ shadow/76770.tmp.11163 2005-11-20 08:55:07.000000000 -0500
@@ -0,0 +1,206 @@
+Bug#: 76770
+Product: Mono: Class Libraries
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Major
+Component: Windows.Forms
+AssignedTo: peter at novonyx.com
+ReportedBy: federico.giampietro at studifin.it
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: DataGrid error
+
+Hello,
+I have problem to reuse a datagrid with a new TableStyle.
+When I do "dataGrid1.TableStyles.Clear()" to remove old TableStyle, I get
+the following error:
+
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+in [0x00018] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs:1955)
+System.Windows.Forms.DataGrid:OnTableStylesCollectionChanged (System.Object
+sender, System.ComponentModel.CollectionChangeEventArgs e)
+in (wrapper delegate-invoke)
+System.MulticastDelegate:invoke_void_object_CollectionChangeEventArgs
+(object,System.ComponentModel.CollectionChangeEventArgs)
+in [0x00013] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTableStylesCollection.cs:182)
+System.Windows.Forms.GridTableStylesCollection:OnCollectionChanged
+(System.ComponentModel.CollectionChangeEventArgs ccevent)
+in [0x00013] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridTableStylesCollection.cs:113)
+System.Windows.Forms.GridTableStylesCollection:Clear ()
+in (wrapper remoting-invoke-with-check)
+System.Windows.Forms.GridTableStylesCollection:Clear ()
+in [0x001ec] (at /home/federico/MonoTest/sctest/Caronte.cs:991)
+StudiFinanziari.Caronte:button5_Click (System.Object sender,
+System.EventArgs e)
+in (wrapper delegate-invoke)
+System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs)
+in [0x00013] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:3779)
+System.Windows.Forms.Control:OnClick (System.EventArgs e)
+in [0x0002c] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:96)
+System.Windows.Forms.Button:OnClick (System.EventArgs e)
+in [0x000a6] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs:481)
+System.Windows.Forms.ButtonBase:OnMouseUp
+(System.Windows.Forms.MouseEventArgs mevent)
+in [0x00002] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:100)
+System.Windows.Forms.Button:OnMouseUp (System.Windows.Forms.MouseEventArgs e)
+in [0x0023f] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:3526)
+System.Windows.Forms.Control:WndProc (System.Windows.Forms.Message m)
+in [0x00057] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs:530)
+System.Windows.Forms.ButtonBase:WndProc (System.Windows.Forms.Message m)
+in [0x00002] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:113)
+System.Windows.Forms.Button:WndProc (System.Windows.Forms.Message m)
+in [0x00007] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:150)
+System.Windows.Forms.Control+ControlNativeWindow:WndProc
+(System.Windows.Forms.Message m)
+in [0x00056] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs:141)
+System.Windows.Forms.NativeWindow:WndProc (IntPtr hWnd, Msg msg, IntPtr
+wParam, IntPtr lParam)
+in [0x0001c] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs:2174)
+System.Windows.Forms.XplatUIX11:DispatchMessage (System.Windows.Forms.MSG msg)
+in [0x00006] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs:360)
+System.Windows.Forms.XplatUI:DispatchMessage (System.Windows.Forms.MSG msg)
+in [0x000fd] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:353)
+System.Windows.Forms.Application:Run ()
+in [0x0004a] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:385)
+System.Windows.Forms.Application:Run
+(System.Windows.Forms.ApplicationContext context)
+in [0x0000c] (at
+/tmp/scratch/BUILD/mono-1.1.10/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:376)
+System.Windows.Forms.Application:Run (System.Windows.Forms.Form mainForm)
+in [0x00005] (at /home/federico/MonoTest/sctest/Caronte.cs:823)
+StudiFinanziari.Caronte:Main ()
+
+This is the piece of code, that runs without problem on MS .NET:
+ int nrighe = dataset.Tables[tabella].Rows.Count;
+
+ int ncolonne = dataset.Tables[tabella].Columns.Count;
+
+ Colonna[] colonne = new Colonna[ncolonne];
+
+ int larghezza = 0;
+
+ int size = 0;
+ label3.Text = "Stili: " + dataGrid1.TableStyles.Count.ToString();
+ dataGrid1.TableStyles.Clear();
+
+ DataGridTableStyle ts1 = new DataGridTableStyle();
+ ts1.MappingName = tabella;
+
+ for (int i = 0; i < ncolonne; i++)
+
+ {
+
+ colonne[i].nome = dataset.Tables[tabella].Columns[i].ColumnName;
+
+ colonne[i].tipo = dataset.Tables[tabella].Columns[i].DataType.ToString();
+
+ larghezza = colonne[i].nome.Length;
+
+ for(int j = 0; j < nrighe; j++)
+
+ {
+
+ size = dataset.Tables[tabella].Rows[j].ItemArray[i].ToString().Length;
+
+ if(size > larghezza)
+
+ larghezza = size;
+
+ }
+
+ if ( colonne[i].tipo == "System.DateTime")
+
+ larghezza /= 2;
+
+ colonne[i].larghezza = larghezza;
+
+ }
+
+ for (int i = 0; i < ncolonne; i++)
+
+ {
+
+ if (colonne[i].nome != "verificato")
+
+ {
+
+ DataGridTextBoxColumn TextCol = new DataGridTextBoxColumn();
+
+ TextCol.MappingName = colonne[i].nome;
+
+ TextCol.HeaderText = colonne[i].nome;
+
+ TextCol.Width = colonne[i].larghezza * 7 + 10;
+
+ //TextCol.NullText = "";
+
+ ts1.GridColumnStyles.Add(TextCol);
+
+ }
+
+ else
+
+ {
+
+ DataGridBoolColumn BoolCol = new DataGridBoolColumn();
+
+ BoolCol.MappingName = colonne[i].nome;
+
+ BoolCol.HeaderText = colonne[i].nome;
+
+ BoolCol.TrueValue = (string) "1";
+
+ BoolCol.FalseValue = (string) "0";
+
+ BoolCol.ReadOnly = false;
+
+ BoolCol.AllowNull = false;
+
+ ts1.GridColumnStyles.Add(BoolCol);
+
+ }
+
+ }
+
+ dataGrid1.TableStyles.Add(ts1);
+
+ DataGridBoolColumn myGridColumn =
+(DataGridBoolColumn)dataGrid1.TableStyles[0].GridColumnStyles["verificato"];
+ if (myGridColumn != null)
+
+ myGridColumn.AllowNull = false;
+
+ dataGrid1.SetDataBinding(dataset, tabella);
+
+ dataGrid1.Refresh();
+
+ dataGrid1.Focus();
+
+ label5.Text = "Righe: " + dbops.dblTblGetRowNumber(tabella);
+
+
+
+Bye, Federico
More information about the mono-bugs
mailing list