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. refreshing datagrids

refreshing datagrids

Scheduled Pinned Locked Moved C#
questionannouncement
2 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.
  • A Offline
    A Offline
    Ashwin C
    wrote on last edited by
    #1

    i have bound a dataset to a datagrid ... now .. private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e) { temp = e.Start.Date; DateTime dt; dataGridView1.Update(); foreach (DataGridViewRow dr in dataGridView1.Rows) { dt = System.Convert.ToDateTime(dr.Cells[2].Value); // textBox3.Text = dr.Cells[2].FormattedValue.ToString(); if (dr.Cells[2].Value != null && dt.Date.Month != temp.Month) // dataGridView1.Rows.Remove(dr); DataTable1DataConnector.RemoveCurrent(); } } what im trying to do here is ... i have a monthcalender object on the form .. and when i change the month ..i want to re-populate the datagridview such that it displays only entries of that month ... how do i do this ? here it does del the entries whihc are not of that month .. but doest repopulate again !

    H 1 Reply Last reply
    0
    • A Ashwin C

      i have bound a dataset to a datagrid ... now .. private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e) { temp = e.Start.Date; DateTime dt; dataGridView1.Update(); foreach (DataGridViewRow dr in dataGridView1.Rows) { dt = System.Convert.ToDateTime(dr.Cells[2].Value); // textBox3.Text = dr.Cells[2].FormattedValue.ToString(); if (dr.Cells[2].Value != null && dt.Date.Month != temp.Month) // dataGridView1.Rows.Remove(dr); DataTable1DataConnector.RemoveCurrent(); } } what im trying to do here is ... i have a monthcalender object on the form .. and when i change the month ..i want to re-populate the datagridview such that it displays only entries of that month ... how do i do this ? here it does del the entries whihc are not of that month .. but doest repopulate again !

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Bind against a DataView instead. You can set the RowFilter which may or may not update the DataSet automatically. If it doesn't, one way is to assign null to the DataGrid and then assign the DataView back. You could also get the CurrencyManager from the BindingContext and call CurrencyManager.Refresh. That would be the preferred method. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

      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