Here ItemName will be Enable/Disable According to IsApplicable Property
Assembly:
DevExpress.XtraLayout;
DevExpress.ExpressApp.Win.Layout;
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.HideToCustomization();
}
else
{
target.RestoreFromCustomization();
}
layoutControl.EndUpdate();
}
}
Here is Method
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;
}
Monday, October 26, 2009
How To Rename a TAB on DetailView
To Rename a TAB you have to Make a Method given below
Assembly:
DevExpress.XtraLayout;
DevExpress.ExpressApp.Win.Layout;
public void RenameTab(DetailView view, string tabName, bool isVisible)
{ LayoutControl layoutControl = ((LayoutControl)view.Control); foreach (object obj in layoutControl.Items) { if (obj is TabbedControlGroup) { TabbedControlGroup tabbedControlGroup = (TabbedControlGroup)obj; foreach (object item in tabbedControlGroup.TabPages) { string Name = ((LayoutGroup)(item)).Name; if (Name.IndexOf("OriginalTABName1") >= 0 || Name.IndexOf("OrignalTABName2") >= 0) { if (Name.IndexOf(tabName) <= 0) { ((LayoutGroup)(item)).BeginUpdate(); ((LayoutGroup)(item)).CustomizationFormText = tabName; ((LayoutGroup)(item)).Text = tabName; ((LayoutGroup)(item)).EndUpdate(); } return;}}}} layoutControl.EndUpdate(); } Now Write Code on ObjectChange void ObjectSpace_ObjectChanged(object sender, ObjectChangedEventArgs e) { if (View is DetailView && View.ObjectTypeInfo.Type == typeof(Ledger)) { if (e.Object.GetType() == typeof(Ledger)) { LayoutControl layoutControl = ((LayoutControl)View.Control); DetailView dv = (DetailView)View; Ledger ldg = (Ledger)View.CurrentObject; LayoutControlItem target = FindLayoutControlItemByName("DeducteeType", ((LayoutControl)(((WinLayoutManager)(dv.LayoutManager)).Container)).Items); ITypeInfo imf = (ITypeInfo)XafTypesInfo.Instance.FindTypeInfo(View.CurrentObject.GetType()); IMemberInfo imi = imf.FindMember("IsTDSApplicable"); Boolean ValueOfIsTDSApplicable = false; if (imi != null) { ValueOfIsTDSApplicable = (Boolean)imi.GetValue(View.CurrentObject); } layoutControl.BeginUpdate(); if (target != null && ValueOfIsTDSApplicable) { RenameTab(dv, "TDSDetails", true); target.Text = "DeducteeType"; } else { RenameTab(dv, "TCSDetails", true); target.Text = "CollecteeType"; } layoutControl.EndUpdate(); }}}
Assembly:
DevExpress.XtraLayout;
DevExpress.ExpressApp.Win.Layout;
public void RenameTab(DetailView view, string tabName, bool isVisible)
{ LayoutControl layoutControl = ((LayoutControl)view.Control); foreach (object obj in layoutControl.Items) { if (obj is TabbedControlGroup) { TabbedControlGroup tabbedControlGroup = (TabbedControlGroup)obj; foreach (object item in tabbedControlGroup.TabPages) { string Name = ((LayoutGroup)(item)).Name; if (Name.IndexOf("OriginalTABName1") >= 0 || Name.IndexOf("OrignalTABName2") >= 0) { if (Name.IndexOf(tabName) <= 0) { ((LayoutGroup)(item)).BeginUpdate(); ((LayoutGroup)(item)).CustomizationFormText = tabName; ((LayoutGroup)(item)).Text = tabName; ((LayoutGroup)(item)).EndUpdate(); } return;}}}} layoutControl.EndUpdate(); } Now Write Code on ObjectChange void ObjectSpace_ObjectChanged(object sender, ObjectChangedEventArgs e) { if (View is DetailView && View.ObjectTypeInfo.Type == typeof(Ledger)) { if (e.Object.GetType() == typeof(Ledger)) { LayoutControl layoutControl = ((LayoutControl)View.Control); DetailView dv = (DetailView)View; Ledger ldg = (Ledger)View.CurrentObject; LayoutControlItem target = FindLayoutControlItemByName("DeducteeType", ((LayoutControl)(((WinLayoutManager)(dv.LayoutManager)).Container)).Items); ITypeInfo imf = (ITypeInfo)XafTypesInfo.Instance.FindTypeInfo(View.CurrentObject.GetType()); IMemberInfo imi = imf.FindMember("IsTDSApplicable"); Boolean ValueOfIsTDSApplicable = false; if (imi != null) { ValueOfIsTDSApplicable = (Boolean)imi.GetValue(View.CurrentObject); } layoutControl.BeginUpdate(); if (target != null && ValueOfIsTDSApplicable) { RenameTab(dv, "TDSDetails", true); target.Text = "DeducteeType"; } else { RenameTab(dv, "TCSDetails", true); target.Text = "CollecteeType"; } layoutControl.EndUpdate(); }}}
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();
}
}
Thursday, October 1, 2009
How To DeleteDuplicateRecord From ArrayList
ar is ArrayList
int index;
for(int i=0; i<(ar.Count-1); i++)
{
index=ar.IndexOf(ar[i], i+1);
while( index>i )
{
ar.RemoveAt(index);
if( i<(ar.Count-1) )
{
index=ar.IndexOf(ar[i], i+1);
}
else
{
index=-1;
}
}
}
How To Get Property Value From Application Model
string s = null;
s = Application.Info.GetChildNode("Options").GetAttribute("CalculationOnObject").Value;
Auto Index in GridView
void gv_InitNewRow(object sender, InitNewRowEventArgs e)
{
GridView gvv = (GridView)sender;
int a = 1;
for (int i = 1; i <= gvv.RowCount; i++)
{
gvv.SetRowCellValue(e.RowHandle, "Index", a);
a++;
}
}
Subscribe to:
Posts (Atom)
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...
-
Angular is a JavaScript open-source front-end web application framework. Learn and Start Angular 6 https://youtu.be/iCczsazLY-E ...
-
SortingCollection sc = new SortingCollection(); sc.Add (new SortProperty("field on which you want to sort",DevExpress.Xpo.DB.Sorti...
-
Build Angular App for Production while you plan for production release then keep these things in Mind ng build --prod --base--hre...