Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DataGridView throwing Drawing exception when assigning datasource

DataGridView throwing Drawing exception when assigning datasource

Scheduled Pinned Locked Moved C#
databasegraphicshelpcsharpsqlite
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Groulien
    wrote on last edited by
    #1

    Hello CP, I've run into a problem while working on an interface for the result of raw SQL. The user inputs the raw SQL code and the form renders a result, it's an educational piece of software so nothing too fancy. Now, the problem I have is that after putting the result into a DataTable, it crashes when I pass it as a DataSource for the DataGridView. The database I'm querying is an MSAccess (2003, mdb) database. Oddly enough, it doesn't misbehave (crash) when I'm using an SQLite database. I would like some help since the stacktrace isn't making sense to me.

    Quote:

    A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll System.Transactions Critical: 0 : http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/UnhandledUnhandled exceptionSimpelQL.Net.vshost.exeSystem.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Parameter is not valid. at System.Drawing.Font.GetHeight(Graphics graphics) at System.Drawing.Font.GetHeight() at System.Drawing.Font.get_Height() at System.Windows.Forms.DataGridViewRow..ctor() at System.Windows.Forms.DataGridView.get_RowTemplateClone() at System.Windows.Forms.DataGridView.RefreshRows(Boolean scrollIntoView) at System.Windows.Forms.DataGridView.RefreshColumnsAndRows() at System.Windows.Forms.DataGridView.OnDataSourceChanged(EventArgs e) at System.Windows.Forms.DataGridView.set_DataSource(Object value) at Proj.Net.MainForm.evt_Exec(Object sender, EventArgs e) in L:\Dev\Proj.Net\MainForm.cs:line 139

    The first rule of CListCtrl is you do not talk about CListCtrl - kornman

    L 1 Reply Last reply
    0
    • G Groulien

      Hello CP, I've run into a problem while working on an interface for the result of raw SQL. The user inputs the raw SQL code and the form renders a result, it's an educational piece of software so nothing too fancy. Now, the problem I have is that after putting the result into a DataTable, it crashes when I pass it as a DataSource for the DataGridView. The database I'm querying is an MSAccess (2003, mdb) database. Oddly enough, it doesn't misbehave (crash) when I'm using an SQLite database. I would like some help since the stacktrace isn't making sense to me.

      Quote:

      A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll System.Transactions Critical: 0 : http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/UnhandledUnhandled exceptionSimpelQL.Net.vshost.exeSystem.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Parameter is not valid. at System.Drawing.Font.GetHeight(Graphics graphics) at System.Drawing.Font.GetHeight() at System.Drawing.Font.get_Height() at System.Windows.Forms.DataGridViewRow..ctor() at System.Windows.Forms.DataGridView.get_RowTemplateClone() at System.Windows.Forms.DataGridView.RefreshRows(Boolean scrollIntoView) at System.Windows.Forms.DataGridView.RefreshColumnsAndRows() at System.Windows.Forms.DataGridView.OnDataSourceChanged(EventArgs e) at System.Windows.Forms.DataGridView.set_DataSource(Object value) at Proj.Net.MainForm.evt_Exec(Object sender, EventArgs e) in L:\Dev\Proj.Net\MainForm.cs:line 139

      The first rule of CListCtrl is you do not talk about CListCtrl - kornman

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Do you have a custom paint-handler? Any other event that is triggered on a refresh, using Fonts? Cover the lot with breakpoints, and show us some code :)

      Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

      G 1 Reply Last reply
      0
      • L Lost User

        Do you have a custom paint-handler? Any other event that is triggered on a refresh, using Fonts? Cover the lot with breakpoints, and show us some code :)

        Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

        G Offline
        G Offline
        Groulien
        wrote on last edited by
        #3

        I went a whole lot simpler and it's still throwing exceptions.

        private void frm_Shown(object sender, EventArgs e)
        {
        DataTable t = new DataTable();
        t.Columns.Add("a");
        t.Columns.Add("b");
        t.Rows.Add("a","b");
        System.Diagnostics.Debug.Assert(t.IsInitialized == true);
        dataGridView1.DataSource = t;
        }

        I have no idea why this is bugging.

        The first rule of CListCtrl is you do not talk about CListCtrl - kornman

        L 1 Reply Last reply
        0
        • G Groulien

          I went a whole lot simpler and it's still throwing exceptions.

          private void frm_Shown(object sender, EventArgs e)
          {
          DataTable t = new DataTable();
          t.Columns.Add("a");
          t.Columns.Add("b");
          t.Rows.Add("a","b");
          System.Diagnostics.Debug.Assert(t.IsInitialized == true);
          dataGridView1.DataSource = t;
          }

          I have no idea why this is bugging.

          The first rule of CListCtrl is you do not talk about CListCtrl - kornman

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I do; this is not all code. You've prolly got drawing-events assigned, check out what happens if you put them into comments. Or paste enough code to reproduce the problem on the board :)

          Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups