Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys.

1. I've created a Own Class, called "Text" (in my namespace "Data.Core").

2. I've created a DataTable-Object called "oDataTable".

3. I've Added a Column to this Object by using the following Code:

C#
oDataTable.Columns.Add("Deutsch", typeof(Data.Core.Text));


4. I've created several DataRows to this DataTable-Object, which contains Text-Objects

4. I've set the DataTable to the ItemSource of a DataGrid (WPF .Net 4.0) and Bound a String-Property of my Text-Object to display in my Grid.

5. No I want to set a Filter. My First Idea was using the RowFilter-Property of my
DataTables DefaultView-Property. But there appears an EvaluateException:
"Can't convert Data.Core.Text into System.String".
Is there a common way to handle this problem or have I to create a workaround ?
Posted
Updated 29-Sep-11 22:04pm
v2

1 solution

Supply your class with a implicit conversion operator for System.String, see Using Conversion Operators[^] for an explanation.
 
Share this answer
 
Comments
Jeff.Jefferson 11-Oct-11 2:38am    
That really works ?

I've put these code in my "Text"-Class.
<pre lang="c#">
public static implicit operator string(Text t)
{
return t.Caption;
}</pre>

Caption is a string-Property of my Text-Class.

The same Error occurs :-S

But i have a question to the Conversion operators....

Can there occur a conflict by implement this Conversion for Strings and a "override ToString()-Method" ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900