Hello everybody
I have a WinGrid which DataSource is made from a Linq Query. Everything works fine. Now, when I try to Format a Column like
e.Layout.Bands[0].Columns[
"ColumnName"].Format = "{0:##,##0.00}";
the Format ist not accepted. Following things I already tried:
It doesn't matter what I try, the Format is not accepted.
I am working with Infragistics Winforms 9.1
Thanks for help
The grid doesn't know or care where the data came from, it communicates with the binding manager. One thing you could do is check the DataType of the DataColumn that is generated for the 'Budget' column in each scenario and see what the difference, if any, is. If there is no difference, you can attach a simple sample here if you like and we can take a look.
Hello
The Column 'ColumnName' is actually of Type long. I tried first with the type long, then I casted the type of the Column 'ColumnName' to string. Neither was working.
I better let you know more about my code. The base of my datasource are two dataset. One dataset is filled from a SQL-Server 2005 Database. The other from an oracle database. To merge this two datasets I use the following linq-query:
//DataSet from SQL-Server
DataSet dsPlaene = this.auftrag.DBMethods.PlanSelectHochrechnung();
//DataSet from Oracle
DataSet dsBelegeH = this.auftrag.DBMethods.BelegeSumPerKostenart();
DataTable Plaene = dsPlaene.Tables[0].Copy();
Plaene.TableName = "Plaene";
DataTable BelegeH = dsBelegeH.Tables[0].Copy();
BelegeH.TableName = "Belege";
var Hochrechnung = from p in Plaene.AsEnumerable()
join bh in BelegeH.AsEnumerable()
on p.Field<string>("KostenartNummer") equals bh.Field<string>("KostenartNummer")
into g
from bh in g.DefaultIfEmpty()
select new
{
PlanID = p.Field<long>("PlanID"),
KostenartNummer = p.Field<string>("KostenartNummer"),
KostenartBezeichnung = p.Field<string>("KostenartBezeichnung"),
Gesamtkredit = p.Field<long>("Gesamtkredit"),
Budget = p.Field<long>("Budget"),
Ist = (bh == null ? 0 : bh.Field<decimal>("Betrag")),
Differenz = (p.Field<long>("Budget") - (bh == null ? 0 : bh.Field<decimal>("Betrag"))).ToString(),
Hochrechnung = p.Field<long>("Hochrechnung"),
Abweichung = p.Field<long>("Abweichung"),
AbweichungProzent = p.Field<long>("AbweichungProzent"),
Begruendung = p.Field<string>("HochrechnungBegruendung")};
//Convert Hochrechnung to a dataset
//Set the dataset 'datasetH' to the grid's DataSource
gridHochrechnung.DataSource = datasetH;
The Column 'Budget' should now be formated. So that's why I put the following could in the initialize_layout event:
e.Layout.Bands[0].Columns["Budget"].Format = "{0:##,##0.00}";
There is no further definitions for the column 'Budget'
If the grid has a normal (not merged with linq) dataset as its DataSource, everything works fine and the format will be accepted.
What wrong have I done. Please help
Thanks
Going by the code you pasted, you are setting the Format for a column named 'ColumnName', which I'm guessing is of type string. Formats are not applied to string data values.