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. Collection editor problem

Collection editor problem

Scheduled Pinned Locked Moved C#
helpvisual-studioquestioncsharpcss
3 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.
  • D Offline
    D Offline
    dacris
    wrote on last edited by
    #1

    Consider this. There's a custom control, MyCtl which displays a tree of items. It has a collection of MyItem objects. Both MyCtl and MyItem have item collections (that is, you can have sub-items, sub-sub-items, and so forth). The item collections in MyCtl and MyItem are marked as DesignerSerializationVisibility.Content, so that they are saved in the code when modified through the designer. Items can successfully be added to the item collection of the MyCtl control, through the designer (collection editor). When sub-items are added, with the Collection Editor, an "Object reference not set to an instance of an object" message comes up when OK is clicked and the sub-items are lost. :(( I've created a small test project to show you this behavior, along with a set of instructions, shown below. The ZIP file of the sample project is found at: http://www.dacris.com/collections.zip *ZIP file updated with VS.NET 2002 project files Here are the instructions: 1. Open the attached Zip file and extract it to an empty folder. 2. Open Collections.sln in the VS.NET IDE. 3. Build the solution to generate the Collections class library. 4. Open Form1.cs in the Windows Forms designer. 5. Select the control containing the tree of strings (it is set to DockStyle=Fill, so just click the form's client area). 6. Scroll the property grid all the way down. 7. Click the '...' button next to the Items collection property. 8. Select the third item in the list of items. 9. In the property grid for that item, select the '...' button next to the Items collection property. 10. Click the Add button on the dialog box that comes up. 11. Select the newly added item and enter a string value for the Text property (such as 'The disappearing item') in the property grid of the newly added item. 12. Click OK. Notice how the item has appeared on the control in the form, and it is called 'The disappearing item'. 13. Click OK again on the dialog box that remains. An "Object reference not set to an instance of an object" message should appear. Click OK. 14. Click Cancel. Another message will appear. Click OK to close it. 15. Click Cancel again. Notice how the item has now disappeared from both the control and the component tray, and the Form1 window is not marked as modified (asterisk). How can I get the items to persist on infinite depth levels? How on earth did MS do it with the TreeView and Menu controls? :confused: I am stuck and I need your help. I shal

    L 1 Reply Last reply
    0
    • D dacris

      Consider this. There's a custom control, MyCtl which displays a tree of items. It has a collection of MyItem objects. Both MyCtl and MyItem have item collections (that is, you can have sub-items, sub-sub-items, and so forth). The item collections in MyCtl and MyItem are marked as DesignerSerializationVisibility.Content, so that they are saved in the code when modified through the designer. Items can successfully be added to the item collection of the MyCtl control, through the designer (collection editor). When sub-items are added, with the Collection Editor, an "Object reference not set to an instance of an object" message comes up when OK is clicked and the sub-items are lost. :(( I've created a small test project to show you this behavior, along with a set of instructions, shown below. The ZIP file of the sample project is found at: http://www.dacris.com/collections.zip *ZIP file updated with VS.NET 2002 project files Here are the instructions: 1. Open the attached Zip file and extract it to an empty folder. 2. Open Collections.sln in the VS.NET IDE. 3. Build the solution to generate the Collections class library. 4. Open Form1.cs in the Windows Forms designer. 5. Select the control containing the tree of strings (it is set to DockStyle=Fill, so just click the form's client area). 6. Scroll the property grid all the way down. 7. Click the '...' button next to the Items collection property. 8. Select the third item in the list of items. 9. In the property grid for that item, select the '...' button next to the Items collection property. 10. Click the Add button on the dialog box that comes up. 11. Select the newly added item and enter a string value for the Text property (such as 'The disappearing item') in the property grid of the newly added item. 12. Click OK. Notice how the item has appeared on the control in the form, and it is called 'The disappearing item'. 13. Click OK again on the dialog box that remains. An "Object reference not set to an instance of an object" message should appear. Click OK. 14. Click Cancel. Another message will appear. Click OK to close it. 15. Click Cancel again. Notice how the item has now disappeared from both the control and the component tray, and the Form1 window is not marked as modified (asterisk). How can I get the items to persist on infinite depth levels? How on earth did MS do it with the TreeView and Menu controls? :confused: I am stuck and I need your help. I shal

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      It would help if I could open VS.NET 2003 beta files.....:( "I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.

      D 1 Reply Last reply
      0
      • L leppie

        It would help if I could open VS.NET 2003 beta files.....:( "I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.

        D Offline
        D Offline
        dacris
        wrote on last edited by
        #3

        Oops..ok i'll fix that. download again in about 5 minutes. sorry

        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