wpf - No Overload for method "GetValue" takes 1 arguments -
i trying run devexpress dxgrid sample program. here
the vertical grid code :
using devexpress.data; using devexpress.xpf.editors.settings; using devexpress.xpf.grid; using system; using system.collections; using system.collections.objectmodel; using system.collections.specialized; using system.componentmodel; using system.linq; using system.reflection; using system.windows; using system.windows.controls; using system.windows.data; namespace dxexample.vgrid { public partial class verticalgridcontrol : gridcontrol { inotifycollectionchanged backitemssourceevents; object internalitemssource { { return base.itemssource; } set { base.itemssource = value; } } gridcolumncollection internalcolumns { { return base.columns; } } public verticalrowcollection rows { get; set; } public bool autopopulaterows { { return (bool)getvalue(autopopulaterowsproperty); } set { setvalue(autopopulaterowsproperty, value); } } public new object itemssource { { return (object)getvalue(itemssourceproperty); } set { setvalue(itemssourceproperty, value); } } public verticalgridcontrol() { initializecomponent(); initializerowscollection(); subscribeitemssourcepropertychanged(); } void initializerowscollection() { rows = new verticalrowcollection(); rows.collectionchanged += onrowscollectionchanged; } void updaterowscollection() { if (autopopulaterows) { populaterows(); } } void subscribeitemssourcepropertychanged() { dependencypropertydescriptor itemssourcedropertydescriptor = dependencypropertydescriptor.fromproperty(verticalgridcontrol.itemssourceproperty, typeof(verticalgridcontrol)); itemssourcedropertydescriptor.addvaluechanged(this, new eventhandler(onitemssourcepropertychanged)); } void updateinternalcolumns() { icollection itemssource = (itemssource icollection); if (itemssource == null) { columns.clear(); return; } columns.beginupdate(); int columnscount = itemssource.count; if (internalcolumns.count == columnscount) return; int delta = columnscount - internalcolumns.count; if (columnscount > internalcolumns.count) { (int = internalcolumns.count; < columnscount; i++) { internalcolumns.add(new gridcolumn() { fieldname = i.tostring(), unboundtype = unboundcolumntype.object }); } } else { (int = internalcolumns.count - 1; >= columnscount; i--) { internalcolumns.removeat(i); } } columns.endupdate(); } void updateitemssourceeventssubscription() { if (backitemssourceevents != null) { backitemssourceevents.collectionchanged -= onitemssourcecollectionchanged; } if (!(itemssource inotifycollectionchanged)) return; inotifycollectionchanged itemssourceevents = (itemssource inotifycollectionchanged); itemssourceevents.collectionchanged += onitemssourcecollectionchanged; backitemssourceevents = itemssourceevents; } void populaterows() { ienumerable itemssource = (itemssource ienumerable); if (itemssource == null) return; ienumerator itemssourceenumerator = itemssource.getenumerator(); itemssourceenumerator.movenext(); object item = itemssourceenumerator.current; if (item == null) return; propertyinfo[] itemprops = item.gettype().getproperties(); (int = 0; < itemprops.length; i++) { rows.add(verticalrowdata.frompropertyinfo(itemprops[i])); } } void onrowscollectionchanged(object sender, notifycollectionchangedeventargs e) { internalitemssource = rows; } void onitemssourcepropertychanged(object sender, eventargs e) { updateinternalcolumns(); updaterowscollection(); updateitemssourceeventssubscription(); } void onitemssourcecollectionchanged(object sender, notifycollectionchangedeventargs e) { if (e.action == notifycollectionchangedaction.add || e.action == notifycollectionchangedaction.remove) { updateinternalcolumns(); } } void onprocessunboundcolumndata(object sender, gridcolumndataeventargs e) { ilist itemssource = (itemssource ilist); if (itemssource == null) return; verticalrowdata row = rows[e.listsourcerowindex]; object item = itemssource[convert.toint32(e.column.fieldname)]; propertyinfo itemproperty = item.gettype().getproperty(row.rowname); if (itemproperty == null) return; if (e.isgetdata) { e.value = itemproperty.getvalue(item); } if (e.issetdata) { itemproperty.setvalue(item, e.value); } } public static readonly dependencyproperty autopopulaterowsproperty = dependencyproperty.register("autopopulaterows", typeof(bool), typeof(verticalgridcontrol), new propertymetadata(false)); public static new readonly dependencyproperty itemssourceproperty = dependencyproperty.register("itemssource", typeof(object), typeof(verticalgridcontrol), new propertymetadata(null)); } public class bottomindicatorrowvisibilityconverter : imultivalueconverter { public object convert(object[] values, type targettype, object parameter, system.globalization.cultureinfo culture) { if (values.count() < 2) return visibility.collapsed; if (!((values[0] int) && (values[1] int))) return visibility.collapsed; return ((int)values[0]) > ((int)values[1]) ? visibility.visible : visibility.collapsed; } public object[] convertback(object value, type[] targettypes, object parameter, system.globalization.cultureinfo culture) { throw new notimplementedexception(); } } public class defaultcelltemplateselector : datatemplateselector { public override datatemplate selecttemplate(object item, dependencyobject container) { verticalrowdata row = ((item editgridcelldata).rowdata.row verticalrowdata); if (row.celltemplate == null) return base.selecttemplate(item, container); return row.celltemplate; } } public class verticalrowdata : dependencyobject { public string rowname { get; set; } public datatemplate celltemplate { { return (datatemplate)getvalue(celltemplateproperty); } set { setvalue(celltemplateproperty, value); } } public static readonly dependencyproperty celltemplateproperty = dependencyproperty.register("celltemplate", typeof(datatemplate), typeof(verticalrowdata), new propertymetadata(null)); public static verticalrowdata frompropertyinfo(propertyinfo info) { return new verticalrowdata() { rowname = info.name }; } } public class verticalrowcollection : observablecollection<verticalrowdata> { protected override void insertitem(int index, verticalrowdata item) { int existsindex = indexof(item.rowname); if (existsindex > -1) { if (items[existsindex].celltemplate != null) return; items[existsindex].celltemplate = item.celltemplate; return; } base.insertitem(index, item); } int indexof(string rowname) { (int = 0; < items.count; i++) { if (items[i].rowname == rowname) return i; } return -1; } } } i using visual studio 2010 , .net 4.0, , error getting in "getvalue" , "setvalue" method in onprocessunbounddata function, telling no overload operator takes "1" , "2" operators respectively .
is cause of platform mismatching. please try downloading sample code mentioned above , tell me answer.
thanks, vivek
i looking through lot of forums , tried
e.value = itemproperty.getvalue(item,null); and setvalue :-
itemproperty.setvalue(item, e.value,null); and worked :) anyways... :) :d
Comments
Post a Comment