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. Windows Forms
  4. how i can do that???

how i can do that???

Scheduled Pinned Locked Moved Windows Forms
data-structuresquestion
2 Posts 2 Posters 11 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.
  • U Offline
    U Offline
    User 2830539
    wrote on last edited by
    #1

    i want to bind datagried with an array list full by objects ?:-D

    R 1 Reply Last reply
    0
    • U User 2830539

      i want to bind datagried with an array list full by objects ?:-D

      R Offline
      R Offline
      RabidHamster
      wrote on last edited by
      #2

      The easiest way to bind a data grid with an array list (or any object container, for that matter) is to use Update Controls .NET. You can drop an UpdateGrid on your form and implement the GetItems event. This event just returns the array. Then implement GetCellValue to get the values to display. When the user changes a value, the control fires SetCellValue. Here's an example: private System.Collections.IEnumerable itemsGrid_GetItems() { return _order.Items; } private object itemsGrid_RowAdded() { return _order.NewItem(); } private void itemsGrid_RowDeleted(object tag) { _order.DeleteItem((Item)tag); } private UpdateControls.Forms.ColumnDefinitions itemsGrid_GetColumns() { return new UpdateControls.Forms.ColumnDefinitions(). Add("Name", typeof(string)). Add("Price", typeof(decimal)). Add("Quantity", typeof(int)). AddReadOnly("Total", typeof(decimal)); } private object itemsGrid_GetCellValue(object tag, int column) { Item item = (Item)tag; if (column == 0) return item.Name; else if (column == 1) return item.Price; else if (column == 2) return item.Quantity; else return item.Total; } private void itemsGrid_SetCellValue(object tag, int column, object value) { Item item = (Item)tag; if (column == 0) item.Name = (string)value; else if (column == 1) item.Price = (decimal)value; else if (column == 2) item.Quantity = (int)value; }

      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