[Mono-dev] DataGridView virtual mode, exception

Jonathan Pobst monkey at jpobst.com
Fri Apr 4 11:16:03 EDT 2008


Virtual mode, and indeed much of DataGridView, does not work under Mono 
1.9.  I have been improving it for Mono 2.0, but it is highly unlikely 
that virtual mode will be working by then.

I do not know of any alternatives either.  Perhaps someone else does.

Jonathan


Cetin Sert wrote:
> Dear Mono Devs,
> 
> mono DGVV.exe
> 
> Unhandled Exception: System.NullReferenceException: Object reference not 
> set to an instance of an object
>   at System.Windows.Forms.DataGridView.set_RowCount (Int32 value) [0x00000]
>   at (wrapper remoting-invoke-with-check) 
> System.Windows.Forms.DataGridView:set_RowCount (int)
>   at DGVV.Form1..ctor () [0x00000]
>   at (wrapper remoting-invoke-with-check) DGVV.Form1:.ctor ()
>   at DGVV.Program.Main () [0x00000]
> 
> when setting RowCount property on a DataGridView instance in virtual 
> mode, I get the above exception with Mono 1.2.4, 1.2.6 and 1.9.
> 
> Is virtual mode of DataGridView usable in Mono (1.9)?
> 
> If it is, what am I doing wrong?
> If it is not, what other winforms grid control do you suggest me to use? 
> (It should have a virtual mode support... I tested SourceGrid but it 
> does not draw properly when in virtual mode.)
> 
> Best Regards,
> Cetin Sert
> 
> http://corsis.de
> 
> 
> 
> using System;
> using System.Collections.Generic;
> using System.ComponentModel;
> using System.Data;
> using System.Drawing;
> using System.Text;
> using System.Windows.Forms;
> 
> namespace DGVV
> {
>     public partial class Form1 : Form
>     {
>         public DataGridView dgv = new DataGridView();
> 
>         public Form1()
>         {
>             InitializeComponent();
> 
>             dgv.VirtualMode = true;
> 
>             dgv.CellValueNeeded += new 
> DataGridViewCellValueEventHandler(dgv_CellValueNeeded);
> 
>             // Add columns to the DataGridView.
>             DataGridViewTextBoxColumn companyNameColumn = new 
> DataGridViewTextBoxColumn();
>             companyNameColumn.HeaderText = "Company Name";
>             companyNameColumn.Name = "Company Name";
>             DataGridViewTextBoxColumn contactNameColumn = new 
> DataGridViewTextBoxColumn();
>             contactNameColumn.HeaderText = "Contact Name";
>             contactNameColumn.Name = "Contact Name";
>             dgv.Columns.Add(companyNameColumn);
>             dgv.Columns.Add(contactNameColumn);
>             dgv.AutoSizeColumnsMode = 
> DataGridViewAutoSizeColumnsMode.AllCells;
>             dgv.EditMode = DataGridViewEditMode.EditProgrammatically;
>             dgv.AllowUserToAddRows = false;
>            
>             dgv.RowCount = 4;
>         }
> 
>         void dgv_CellValueNeeded(object sender, 
> DataGridViewCellValueEventArgs e)
>         {
>             switch (e.ColumnIndex)
>             {
>                 case 0:
>                     e.Value = "Sertcom";
>                     break;
> 
>                 case 1:
>                     e.Value = e.RowIndex < 2 ? "Cetin" : "Metin";
>                     break;
>             }
>         }
>     }
> }
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list



More information about the Mono-devel-list mailing list