Click here to Skip to main content
15,907,687 members
Home / Discussions / C#
   

C#

 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Support1239-Nov-06 1:03
Support1239-Nov-06 1:03 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
rah_sin9-Nov-06 1:33
professionalrah_sin9-Nov-06 1:33 
AnswerRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Colin Angus Mackay9-Nov-06 1:00
Colin Angus Mackay9-Nov-06 1:00 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Support1239-Nov-06 1:09
Support1239-Nov-06 1:09 
AnswerRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Hunuman9-Nov-06 1:29
Hunuman9-Nov-06 1:29 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Support1239-Nov-06 1:44
Support1239-Nov-06 1:44 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Colin Angus Mackay9-Nov-06 6:59
Colin Angus Mackay9-Nov-06 6:59 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Pete O'Hanlon9-Nov-06 1:45
mvePete O'Hanlon9-Nov-06 1:45 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Support1239-Nov-06 2:12
Support1239-Nov-06 2:12 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Pete O'Hanlon9-Nov-06 2:27
mvePete O'Hanlon9-Nov-06 2:27 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Support1239-Nov-06 2:32
Support1239-Nov-06 2:32 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Pete O'Hanlon9-Nov-06 4:14
mvePete O'Hanlon9-Nov-06 4:14 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Support1239-Nov-06 5:27
Support1239-Nov-06 5:27 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Pete O'Hanlon9-Nov-06 9:11
mvePete O'Hanlon9-Nov-06 9:11 
QuestionTo make possible to manage position and size of controls by mouse Pin
wasek20018-Nov-06 23:59
wasek20018-Nov-06 23:59 
AnswerRe: To make possible to manage position and size of controls by mouse Pin
mark_w_9-Nov-06 0:27
mark_w_9-Nov-06 0:27 
QuestionRe: To make possible to manage position and size of controls by mouse Pin
wasek20019-Nov-06 4:31
wasek20019-Nov-06 4:31 
QuestionAbstract collection in property grid Pin
mark_w_8-Nov-06 23:56
mark_w_8-Nov-06 23:56 
Hi,

The background:

I have a class "Search" that has a collection in it. This collection is of type "criteria", where "criteria" is an abstract class. The reason being is that i have some concrete classes "IntCriteria", "StringCriteria", "BoolCritera" that i want stored in the collection and they all inherit from "criteria".

To the problem:

I bind "Search" to a property grid, it works fine and i can see/edit all the properties of search, but when i try i add an item to the collection of "criteria" i cant because it does not know what concrete classes to give me as the option to add (see here http://img242.imageshack.us/img242/5803/exampleko9.jpg to see what i want, this is to add columns to a data grid view). Is there a way i can tag "IntCriteria", "StringCriteria" and "BoolCritera" so that the property grid sees them as a type of "criteria".

if not then, is there anyway i can list "IntCriteria", "StringCriteria" or"BoolCritera" in the add new item screen.

Hope that made sense!!!


To Recreate the problem, make a windows application, create this file (i have put multiple classes in one file for ease)(its only example code, not my actual code!)

<br />
using System;<br />
<br />
using System.Collections.Generic;<br />
<br />
using System.Text;<br />
<br />
using System.Collections;<br />
<br />
namespace TestApp<br />
<br />
{<br />
<br />
public class Search<br />
<br />
{<br />
<br />
private string _A;<br />
<br />
private string _B;<br />
<br />
private CriteriaCollection _cc = new CriteriaCollection();<br />
<br />
public string A<br />
<br />
{<br />
<br />
get { return _A; }<br />
<br />
set { _A = value; }<br />
<br />
}<br />
<br />
public string B<br />
<br />
{<br />
<br />
get { return _B; }<br />
<br />
set { _B = value; }<br />
<br />
}<br />
<br />
public CriteriaCollection cc<br />
<br />
{<br />
<br />
get { return _cc; }<br />
<br />
set { _cc = value; }<br />
<br />
}<br />
<br />
public Search()<br />
<br />
{<br />
<br />
}<br />
<br />
}<br />
<br />
public class CriteriaCollection : CollectionBase<br />
<br />
{<br />
<br />
public CriteriaCollection()<br />
<br />
{<br />
<br />
}<br />
<br />
public void Add(Criteria C)<br />
<br />
{<br />
<br />
this.InnerList.Add(C);<br />
<br />
}<br />
<br />
public void Remove(Criteria element)<br />
<br />
{<br />
<br />
InnerList.Remove(element);<br />
<br />
}<br />
<br />
public Criteria this[int index]<br />
<br />
{<br />
<br />
get { return (Criteria)InnerList[index]; }<br />
<br />
}<br />
<br />
public void CopyTo(Criteria[] target, int index)<br />
<br />
{<br />
<br />
InnerList.CopyTo(target, index);<br />
<br />
}<br />
<br />
public int IndexOf(Criteria element)<br />
<br />
{<br />
<br />
return InnerList.IndexOf(element);<br />
<br />
}<br />
<br />
public bool Contains(Criteria element)<br />
<br />
{<br />
<br />
return InnerList.Contains(element);<br />
<br />
}<br />
<br />
public void Insert(int index, Criteria element)<br />
<br />
{<br />
<br />
InnerList.Insert(index, element);<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
//abstract base class, with all the common factors to any criteria<br />
<br />
public abstract class Criteria<br />
<br />
{<br />
<br />
private string _C;<br />
<br />
private string _D;<br />
<br />
<br />
public string C<br />
<br />
{<br />
<br />
get<br />
<br />
{<br />
<br />
return _C;<br />
<br />
}<br />
<br />
set<br />
<br />
{<br />
<br />
_C = value;<br />
<br />
}<br />
<br />
}<br />
<br />
public string D<br />
<br />
{<br />
<br />
get<br />
<br />
{<br />
<br />
return _D;<br />
<br />
}<br />
<br />
set<br />
<br />
{<br />
<br />
_D = value;<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
//Class to deal with any ints<br />
<br />
public class IntCriteria : Criteria<br />
<br />
{<br />
<br />
public IntCriteria()<br />
<br />
{<br />
<br />
<br />
}<br />
<br />
public int DoSomeIntStuff()<br />
<br />
{<br />
<br />
return 0;<br />
<br />
}<br />
<br />
}<br />
<br />
 <br />
<br />
//Class to deal with any strings<br />
<br />
public class StringCriteria : Criteria<br />
<br />
{<br />
<br />
public StringCriteria()<br />
<br />
{<br />
<br />
}<br />
<br />
public string DoSomeStringStuff()<br />
<br />
{<br />
<br />
return "Stuff done";<br />
<br />
}<br />
<br />
}<br />
<br />
//Class to deal with any Bools<br />
<br />
public class BoolCriteria : Criteria<br />
<br />
{<br />
<br />
<br />
public BoolCriteria()<br />
<br />
{<br />
<br />
}<br />
<br />
public bool DoSomeBooleanStuff()<br />
<br />
{<br />
<br />
return true;<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />






Then on a form add a property grid and add

<br />
private void Form1_Load(object sender, EventArgs e)<br />
<br />
{<br />
<br />
Search s = new Search();<br />
<br />
this.propertyGrid1.SelectedObject = s;<br />
<br />
}<br />
<br />




Run the form and try and add and item to cc in the property grid


TIA

Mark
AnswerRe: Abstract collection in property grid Pin
Robert Rohde9-Nov-06 0:52
Robert Rohde9-Nov-06 0:52 
AnswerRe: Abstract collection in property grid Pin
mark_w_9-Nov-06 1:27
mark_w_9-Nov-06 1:27 
QuestionWrapping or creating custom XML elements Pin
TUX2K8-Nov-06 23:39
TUX2K8-Nov-06 23:39 
QuestionLike "VS Watch" control Pin
El'Cachubrey8-Nov-06 23:38
El'Cachubrey8-Nov-06 23:38 
Questionhow to select data from the datagrid Pin
Saira Tanwir8-Nov-06 23:22
Saira Tanwir8-Nov-06 23:22 
AnswerRe: how to select data from the datagrid Pin
rah_sin8-Nov-06 23:45
professionalrah_sin8-Nov-06 23:45 
GeneralRe: how to select data from the datagrid Pin
Saira Tanwir9-Nov-06 0:00
Saira Tanwir9-Nov-06 0:00 

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.