Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: media not adding to play list Pin
uglyeyes14-Jul-09 13:39
uglyeyes14-Jul-09 13:39 
GeneralRe: media not adding to play list Pin
uglyeyes14-Jul-09 17:05
uglyeyes14-Jul-09 17:05 
Questionhow to generate 0's and 1's only through Random Class... Pin
spalanivel13-Jul-09 1:47
spalanivel13-Jul-09 1:47 
AnswerRe: how to generate 0's and 1's only through Random Class... Pin
Anindya Chatterjee13-Jul-09 2:02
Anindya Chatterjee13-Jul-09 2:02 
GeneralRe: how to generate 0's and 1's only through Random Class... Pin
spalanivel13-Jul-09 2:13
spalanivel13-Jul-09 2:13 
GeneralRe: how to generate 0's and 1's only through Random Class... Pin
Anindya Chatterjee13-Jul-09 2:48
Anindya Chatterjee13-Jul-09 2:48 
AnswerRe: how to generate 0's and 1's only through Random Class... Pin
Luc Pattyn13-Jul-09 3:01
sitebuilderLuc Pattyn13-Jul-09 3:01 
QuestionHow to Use PropertyGrid for Complex Class Pin
Anindya Chatterjee13-Jul-09 1:45
Anindya Chatterjee13-Jul-09 1:45 
Suppose I have the following class :

public class A
{
  public bool Boolean {get; set;}

  public List<B> ListOfB {get; set;}  
}

public class B
{
  public String StringValue {get; set;}

  public List<String> OneList {get; set;}

  public List<String> AnotherList {get; set;}
}


I want to expose the class A and under it the B class in a propertygrid. I have tried a lot of thing, but no help. May be I am missing something. What I did is as follows :

[DefaultProperty("ListOfB")]
public class A
{  
  [Browsable(false)]
  public bool Boolean {get; set;}

  [Category("Visuals")]
  [Description("YZYZYZ")]
  [MergableProperty(false)]
  [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  [Localizable(true)]
  [Editor("System.Windows.Forms.Design.ListControlStringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
  [Editor(typeof(BListEditor), typeof(UITypeEditor))]
  public List<B> ListOfB {get; set;}

}

public class B
{
   public String StringValue {get; set;}

   [Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
   [Category("Visuals")]
   [Description("XXYZ")]
   [MergableProperty(true)]
   [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
   public List<String> OneList {get; set;}

   [Description("PPPWRT")]
   [MergableProperty(true)]
   [Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
   [Category("Visuals")]
   [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
   public List<String> AnotherList {get; set;}
}  

public class BListEditor : CollectionEditor
{
   public BListEditor()
     : base(typeof(List<B>  ) )
   { }

   protected override Type[] CreateNewItemTypes()
   {
      return new Type[] {typeof(B)};
   }

   protected override object SetItems(object editValue, object[] value)
   {
      // Cast the context into the expected control type
      A settings = (A)Context.Instance;
      // Let base class update the collection
      object ret = base.SetItems(editValue, value);
                        
      return ret;
   }
}    


I have tried that but no luck. The propertygrid can take the value in collection editor but can't able to store the value. After inserting one B item taking all the data when you click OK nothing actually being inserted into the List of B in class A.

Please help me out.

Thanks in advance.

Anindya Chatterjee
--------------------------------------------------------
1. Don't Visit ..[^]

2. But Watch ..

AnswerRe: How to Use PropertyGrid for Complex Class Pin
Henry Minute13-Jul-09 3:13
Henry Minute13-Jul-09 3:13 
GeneralRe: How to Use PropertyGrid for Complex Class Pin
Anindya Chatterjee13-Jul-09 3:16
Anindya Chatterjee13-Jul-09 3:16 
QuestionUpdating Text File Pin
vishal moharikar13-Jul-09 1:27
vishal moharikar13-Jul-09 1:27 
AnswerRe: Updating Text File Pin
musefan13-Jul-09 4:00
musefan13-Jul-09 4:00 
GeneralRe: Updating Text File Pin
vishal moharikar15-Jul-09 19:20
vishal moharikar15-Jul-09 19:20 
GeneralRe: Updating Text File Pin
musefan15-Jul-09 21:52
musefan15-Jul-09 21:52 
GeneralRe: Updating Text File Pin
vishal moharikar19-Jul-09 18:27
vishal moharikar19-Jul-09 18:27 
Questionhow to check Pin
Nath13-Jul-09 1:19
Nath13-Jul-09 1:19 
AnswerRe: how to check Pin
DaveyM6913-Jul-09 1:27
professionalDaveyM6913-Jul-09 1:27 
AnswerRe: how to check Pin
Nagy Vilmos13-Jul-09 1:29
professionalNagy Vilmos13-Jul-09 1:29 
Questioncreating services in C#.NET Pin
Sujay chakraborty13-Jul-09 0:41
Sujay chakraborty13-Jul-09 0:41 
AnswerRe: creating services in C#.NET Pin
stancrm13-Jul-09 0:48
stancrm13-Jul-09 0:48 
QuestionManaging another .exe from code Pin
Hum Dum13-Jul-09 0:32
Hum Dum13-Jul-09 0:32 
AnswerRe: Managing another .exe from code Pin
Mirko198013-Jul-09 0:39
Mirko198013-Jul-09 0:39 
GeneralRe: Managing another .exe from code Pin
Hum Dum13-Jul-09 1:05
Hum Dum13-Jul-09 1:05 
GeneralRe: Managing another .exe from code Pin
Mirko198013-Jul-09 2:41
Mirko198013-Jul-09 2:41 
AnswerRe: Managing another .exe from code Pin
Anindya Chatterjee13-Jul-09 3:40
Anindya Chatterjee13-Jul-09 3:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.