Monday, October 26, 2009

How To Find LayoutControlItem on DetailView

To find LayoutControlItem you have to create a Method given below here Item is a Class on Which there is two property ItemName,IsApplicable Assembly: DevExpress.XtraLayout; DevExpress.ExpressApp.Win.Layout; when IsApplicable=true then ItemName Caption Property Changed according to your condition private LayoutControlItem FindLayoutControlItemByName(string name, CollectionBase items) { foreach (object item in items) { if (item is LayoutControlItem) { if ((item as LayoutControlItem).ControlName != null) { if ((item as LayoutControlItem).ControlName.IndexOf(name) >= 0) { return item as LayoutControlItem; }}}} return null; } Now Write code on your Desired Event like ControlCreated,ObjectSpace.ObjectChanged if (View is DetailView && View.ObjectTypeInfo.Type == typeof(Item)) { if (e.Object.GetType() == typeof(Item)) { LayoutControl layoutControl = ((LayoutControl)View.Control); DetailView dv = (DetailView)View; Item itm = (Item)View.CurrentObject; LayoutControlItem target = FindLayoutControlItemByName("ItemName", ((LayoutControl)(((WinLayoutManager)(dv.LayoutManager)).Container)).Items); ITypeInfo imf = (ITypeInfo)XafTypesInfo.Instance.FindTypeInfo(View.CurrentObject.GetType()); IMemberInfo imi = imf.FindMember("IsApplicable"); Boolean ValueOfIsApplicable = false; if (imi != null) { ValueOfIsApplicable = (Boolean)imi.GetValue(View.CurrentObject); } layoutControl.BeginUpdate(); if (target != null && ValueOfIsApplicable) { target.Text = "YourDesiredCaption1"; } else { target.Text = "YourDesiredCaption2"; } layoutControl.EndUpdate(); } }

No comments:

Post a Comment

Mat Table Angular

Mat Table in Angular Mat table is used to display data . its a material designed styled data-table . For using Material Table MatTableMo...