[Mono-list] WinForms DataGridView does not add a new Row

Costantino Pipero cos at beeond.net
Tue Apr 20 23:55:40 EDT 2010


I have a very simple Winform app that I want to use to show the  
cross-platform development.

Basically, it's a WinForm DataGrid with 2 buttons that loads/change/save  
to and from an XML file.

It's pretty straight forward, and works perfectly in VS in Windows. It  
compiles and run in Mono and openSuse 11.2, but the DataGrid doesn't add  
the new blank row at the bottom that allows to enter new data (like it  
does in Windows).

Here's the form code



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MonoWinForms
{
     public partial class Form1 : Form
     {
         const string dataFile = "Contacts.xml";

         public Form1()
         {
             InitializeComponent();
         }

         private void Form1_Load(object sender, EventArgs e)
         {
             if (System.IO.File.Exists(dataFile)) LoadData();
             else CreateData();
         }


         private void LoadData()
         {
             dsContacts.ReadXml(dataFile);
         }

         private void CreateData()
         {
             dsContacts.Contacts.AddContactsRow("<First Name>", "<Last  
Name>", "<Email>");
             dsContacts.WriteXml(dataFile, XmlWriteMode.WriteSchema);
         }

         private void btnSave_Click(object sender, EventArgs e)
         {
             dsContacts.Contacts.AcceptChanges();
             dsContacts.Contacts.WriteXml(dataFile,  
XmlWriteMode.WriteSchema);
         }

         private void btnDelete_Click(object sender, EventArgs e)
         {
             dataGridView1.Rows.RemoveAt(dataGridView1.CurrentRow.Index);
             btnSave_Click(sender, e);
         }



     }
}





Thanks for you help, I can send the whole VS solution if it helps (for the  
designer and the dataset)...

Cos


More information about the Mono-list mailing list