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++;
}
}
How To Validate a Row
void gv_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
{
ColumnView columnview = (ColumnView)sender;
GridColumn gridcolumn = columnview.Columns["Date"];
DateTime billdate = Convert.ToDateTime(columnview.GetRowCellValue(e.RowHandle, gridcolumn));
LedgerOpeningBalance lob = (LedgerOpeningBalance)View.CurrentObject;
if (billdate > lob.Date)
{
columnview.SetColumnError(gridcolumn, "Invalid Date !! Date should be Less Than Opening Date", ErrorType.Information);
e.Valid = false;
e.ErrorText = "Invalid Date !! Date should be Less Than Opening Date";
columnview.FocusedRowHandle = e.RowHandle;
columnview.FocusedColumn = gridcolumn;
columnview.ShowEditor();
}
}
How To Filter ListView Staticely
Apply this code after DefaultClassOption this will create a List of Billed, UnBilled,ShowAll
And when you choose option then ListView becomes filter
[ListViewFilter("Billed","BillNo is not null",true)]
[ListViewFilter("UnBilled", "BillNo is null")]
[ListViewFilter("ShowAll", "")]
How To Filter ListView on ControlCreated
((DevExpress.ExpressApp.ListView)View).CollectionSource.Criteria["Filter1"] = new BinaryOperator("Name", "Primary", BinaryOperatorType.NotEqual);
Collection Sorting on Multiple Field
XPCollection xpCollection1 = new XPCollection();
SortingCollection sorting = new SortingCollection();
sorting.Add(new SortProperty("PropertyA", DevExpress.Xpo.DB.SortingDirection.Ascending));
xpCollection1.Sorting = sorting;
...
SortingCollection newSorting = new SortingCollection();
newSorting.Add(new SortProperty("PropertyB", DevExpress.Xpo.DB.SortingDirection.Ascending));
xpCollection1.Sorting = newSorting;
How To Sort a XPCollection
SortingCollection sc = new SortingCollection();
sc.Add (new SortProperty("field on which you want to sort",DevExpress.Xpo.DB.SortingDirection.Ascending));
XpcoletionName.Sorting = sc;
Or
XpcollectionName.Sorting.Add(new SortProperty("field on which you want to sort ", SortingDirection.Ascending));
How To Call a DetailView On Action
Take a View Controller add a SimpaleAction and on Execute Event write Code
ObjectSpace objectSpaceInternal = Application.CreateObjectSpace();
CurrentConfig cc = CurrentConfig.GetCurrentConfig(objectSpaceInternal.Session);
objectSpaceInternal.CommitChanges();
e.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpaceInternal, cc);
e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
e.ShowViewParameters.Context = TemplateContext.PopupWindow;
e.ShowViewParameters.CreateAllControllers = true;
DialogController dcPeriod = new DialogController();
dcPeriod.Accepting += new EventHandler(dcPeriod_Accepting);
e.ShowViewParameters.Controllers.Add(dcPeriod);
Note: currentConfig is class whose detail view you have to call;
How to Find List Selected Item on Accepting
DevExpress.ExpressApp.ListView lv = ((DevExpress.ExpressApp.ListView)((WindowController)sender).Window.View);
lv.SelectedObjects;
How To Call a ListView On Action
Take a View Controller add a SimpaleAction and on Execute Event write Code
And write this code on
ONACTIVATED()Event
simpleAction1.Active.SetItemValue("ObjectType", View.ObjectTypeInfo.Type == typeof(TrialBalance));
ObjectSpace objectSpace = Application.CreateObjectSpace();
CollectionSource collectionSource = (CollectionSource)Application.CreateCollectionSource(objectSpace, typeof(OperationUnit), "OperationUnit_ListView");
ListView listview = Application.CreateListView("OperationUnit_ListView", collectionSource, true);
e.ShowViewParameters.CreatedView = listview;
e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
e.ShowViewParameters.CreateAllControllers = true;
DialogController dcOU = new DialogController();
e.ShowViewParameters.Controllers.Add(dcOU);
dcOU.Accepting += new EventHandler(dcOU_Accepting);
How To Add New Row in ListView
Apply this code above the class
[DefaultListViewOptions(EditMode.Editable,NewItemRowPosition .Bottom)]
Or write own View Controller
GridView gv = (GridView)gc.FocusedView;
gv.NewItemRowText = "Click Here To Add A New Row";
gv.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;
gv.OptionsNavigation.AutoFocusNewRow = true;
gv.OptionsView.ShowFooter = true;
gv.OptionsBehavior.Editable = true;
How To Access The Value Of ReadonlyParameter
DateTime dt = (DateTime)new ToDateParameter().CurrentValue;
CriteriaWrapper criteriaWrapper = new CriteriaWrapper(this.GetType(), "'@ToDate'");
DateTime dt = (DateTime)criteriaWrapper.Parameters[0].CurrentValue;
How to Find Edit value of Lookup
DetailView dv = (DetailView)View;
LookupPropertyEditor control1 = (LookupPropertyEditor)dv.FindItem("AccountGroups");
LookupEdit c1 = (LookupEdit)control1.Control;
AccountGroup gc = (AccountGroup)c1.EditValue;
Comparing Two Property Value in Same class
[RuleCriteria("RuleCriteria for Itemstatus", DefaultContexts.Save, "Date >= StatusDate", "Date should be greater than StatusDate")]
Itemstatus is class Date and StatusDate are Properties and it will be written after [DefaultClassOption]
How to Filter Popup Window
ObjectSpace os = Application.CreateObjectSpace();
ListView listView = Application.CreateListView(Application.GetListViewId(typeof(DomainObject2)), new CollectionSource(os, typeof(DomainObject2)), false);
listView.CollectionSource.Criteria["FilterCriteria"] = CriteriaOperator.Parse("IntProperty > 1");
or
listview.CollectionSource.Criteria["ABC"] = new InOperator("ShipmentNo", al).Not();
or
listview.CollectionSource.Criteria["ABC"] = new BinaryOperator("PropertyName",PropertyValue);
e.View = listView;
Apply Criteria on XPCollection
CriteriaOperator criteria = new BinaryOperator("Age", 30, BinaryOperatorType.Greater);
CriteriaOperator criteria = CriteriaOperator.Parse("Age > 30");
xpCollection1.Criteria = criteria;
CriteriaOperator filter = CriteriaOperator.Parse("Age > 30 AND Age < 40");
xpCollection1.Filter = filter;
gridControl1.DataSource = new XPCollection(Session.DefaultSession, typeof(MyObject),
new BinaryOperator("UnitPrice", filterValue, BinaryOperatorType.GreaterOrEqual));
xpCollection1.Filter = new InOperator("Name", new string[] {"John", "Mike", "Nick"});
CriteriaOperator criteria1 = CriteriaOperator.Parse(
"Iif(Field1 == 100, Field1, Field2) > 1000");
XPCollection collection1 = new XPCollection(typeof(MyObject), criteria1);
class MyObject : XPObject {
decimal unitPrice;
public decimal UnitPrice {
get { return unitPrice; }
set { unitPrice = value; }
}}
// Select MyObject objects that match the specified criteria.
decimal filterValue = 20;
gridControl1.DataSource = new XPCollection(Session.DefaultSession, typeof(MyObject),
new BinaryOperator("UnitPrice", filterValue, BinaryOperatorType.GreaterOrEqual));
CriteriaOperator filter = new BetweenOperator("Age", 20, 30);
xpCustomers.Filter = filter;
// Retrieves a collection of the Contact objects which match the criteria that represents
// the logical expression (DefaultAddress.City <> "Chicago").
XPCollection collection = new XPCollection(typeof(Contact),CriteriaOperator.Parse("DefaultAddress.City != 'Chicago'")
// Retrieves a collection of the Contact objects which match the criteria that represents
// the logical expression (DefaultAddress.City <> "Chicago" AND not (Company is null)).
XPCollection collection = new XPCollection(typeof(Contact),
CriteriaOperator.Parse("DefaultAddress.City != 'Chicago' AND Company is not null")
// Retrieves the Contact objects that contain an address,
// and the city which is given in the address is the same as the person's city.
// The "^" symbol represents a reference to the Owner object,
//The '^' character is used to refer to the parent in a parent-child relationship. The parent relationship traversal operator allows you to access parent objects in expressions written in the context of a child.
// the parent object of the Locations collection.
XPCollection collection = new XPCollection(typeof(Contact),
new ContainsOperator("DefaultAddress.Owner.Locations",
new BinaryOperator(
new OperandProperty("City"), new OperandProperty("^.DefaultAddress.City"),
BinaryOperatorType.Equal
)
)
// Represents the Person class which contains account information.
public class Person: XPObject {
[Association("PersonAccounts", typeof(Account))]
public XPCollection Accounts {
get { return GetCollection("Accounts"); }
}
}
// Represents the Account class which contains the amount in the account.
public class Account: XPObject {
[Association("PersonAccounts")]
public Person Owner;
public int Amount;
}
XPCollection collection = new XPCollection(typeof(Person),
CriteriaOperator.Parse("Accounts.Sum(Amount) < 100")
XPCollection collection = new XPCollection(typeof(Person),
CriteriaOperator.Parse("Accounts[Amount = 0].Count == 1")
CriteriaOperator.Parse("[FirstName] Like 'A%'");
CriteriaOperator.Parse(String.Format("[Address1.City] = '{0}'",City));
CriteriaOperator.Parse("[IsGlobal] = true");
How To To Disable New Button and Close Button From Lookup Window
void View_ControlsCreated(object sender, EventArgs e)
{
if (View is DetailView)
{
LookupPropertyEditor editor = (LookupPropertyEditor)((DetailView)View).FindItem("UnderGroup");
editor.Control.Properties.ShowPopupShadow = true;
editor.Control.Properties.PopupSizeable = false;
editor.Control.Properties.ShowPopupCloseButton = false;
editor.Control.Properties.ShowDropDown = DevExpress.XtraEditors.Controls.ShowDropDown.DoubleClick;
}
}
How To Apply Email validation
[RuleRegularExpression("RuleRegularExpression for classname.propertyname", DefaultContexts.Save, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", "It should be in given format")]
[RuleRequiredField("RuleRequiredField for Company.PhoneNumber", DefaultContexts.Save, "Can Not be Empty you have to Give Phone Number")]
[RuleRange("RuleRange for Payment.Rate", DefaultContexts.Save, 10, 20, "Enter with in range")]
Here payment is a class and rate is property
[RuleUniqueValue("RuleUniqueValue", DefaultContexts.Save, "RuleUniqueValue description")]
[RuleRequiredField("RuleRequiredField for classname.propertyname ", DefaultContexts.Save, "Can Not Be Empty")]
[RuleObjectExists("ClassName_ComplexValidationSettingsObject", DefaultContexts.Save, "CalculationTypes = '@CalculationTypes'AND Amount='@Amount' AND Schedule='@Schedule' AND IsActive='@IsActive'", MessageTemplateMustExist = "Objects with the same combination of the properties must not exist.", InvertResult = true, SkipNullOrEmptyValues = true, FoundObjectMessageFormat = "'{0}'", FoundObjectMessagesSeparator = ";")]
Aassociassion with Module Base
Suppose you have two module
1. Cevious.Xpert.Account
2. Cevious.Xpert.Statutory.In
TCSNature.cs
VAT.cs
In Statutory Module we have used Accounts DLL
In Account module there is a class Ledger in which I want a Lookup of VAT to do this
We go in Cevious.Xpert.Statutory.In =>Module.cs=>
public override void CustomizeTypesInfo(DevExpress.ExpressApp.DC.ITypesInfo typesInfo)
{
base.CustomizeTypesInfo(typesInfo);
XPDictionary xpDCT = XafTypesInfo.XpoTypeInfoSource.XPDictionary;
if (xpDCT.GetClassInfo(typeof(Ledger)).FindMember("PropertyName") == null)
{
xpDCT.GetClassInfo(typeof(Ledger)).CreateMember("PropertyName", typeof(Class Name),new DisplayNameAttribute("Display Name"),new ImmediatePostDataAttribute(),new VisibleInListViewAttribute (false));
Example //xpDCT.GetClassInfo(typeof(Ledger)).CreateMember("Nature", typeof(TypeOfNature));
}
XafTypesInfo.Instance.RefreshInfo(typeof(Ledger));
}
How to Find Property of Class with XafTypeInfo
ITypeInfo ob = XafTypesInfo.Instance.FindTypeInfo(ReflectionHelper.FindType("TransactionDetails")).FindMember("YourPropertyName");
OR
XPDictionary xpd=XafTypeInfo.XpoTypeInfoSource.XPDictionary;
Object ob=(xpd.GetClassInfo((typeof(className)).FindMember(“PropertyName”).GetType());
How To Find GridView From DetailView
ListPropertyEditor lpe = (ListPropertyEditor)dv.FindItem("ShipmentInfo");
GridView gv = (GridView)((GridControl)lpe.ListView.Control).FocusedView;
XPCollection xpc = (XPCollection)(gv.DataSource);
foreach (object ob in xpc)
{
if (ob.GetType() == typeof(BillingFormat))
{ }
How To Hide BO Model For Normal User
SimpleUser Su = (SimpleUser)SecuritySystem.CurrentUser;
if (!Su.IsAdministrator)
{
Frame.GetController().Action.SetActiveByKey("EditModel", false);}
Or
Add a Window Controller
And wrete Code
private void WindowController1_Activated(object sender, EventArgs e)
{
// Window.ViewChanged += new EventHandler(Window_ViewChanged);
}
void Window_ViewChanged(object sender, EventArgs e)
{
IBarManagerHolder template = Window.Template as IBarManagerHolder;
SimpleUser Su = (SimpleUser)SecuritySystem.CurrentUser;
if (Su.IsAdministrator)
{
if (template != null && Window.View != null)
{
foreach (object actionContainer in Window.Template.GetContainers())
{
ActionContainerMenuBarItem mn = actionContainer as ActionContainerMenuBarItem;
{
if (mn != null)
{
if (mn.Actions.Count > 0)
if (mn.Actions[0].Caption == "Edit Model")
{
mn.Actions[0].SetEnabledByKey("Edit Model", false);
}}}}}}}
How to Prevent Deletion Of Record From ListView
In This Controller That Record is Deleted Whose BillNo is Null
Write a Controller and Inherit : DeleteObjectsViewController
protected override void Delete(SimpleActionExecuteEventArgs args)
{
if (View.ObjectTypeInfo.Type == typeof(DispatchRegister))
{
List list = new List();
foreach (DispatchRegister item in args.SelectedObjects)
{
if (item.BillNo==null || item.BillNo.Length<=0)
{
list.Add(item);
}
}
if (list.Count == 0)
{
XtraMessageBox.Show("Record Can Not be Deleted. You Can Delete Only those Record whose Bill No is Blank");
}
else
{
BaseDelete(list);
}
return;
}
base.Delete(args);
}
private void BaseDelete(System.Collections.IList argsSelectedObjects)
{
ObjectSpace.Delete(argsSelectedObjects);
if (AutoCommit || View.IsRoot)
{
ObjectSpace.CommitChanges();
}
if (View is ListView)
{
((ListView)View).Editor.Refresh();
}
else
{
View.Close();
}
}
How to Prevent a DetailView From being Shown When the User Double Clicks/Presses the Enter Key on a Record in the ListView
namespace Solution1.Module.Win {
public partial class ViewController1 : DevExpress.ExpressApp.SystemModule.ListViewProcessCurrentObjectController {
public ViewController1() {
InitializeComponent();
RegisterActions(components);
}
protected override void ExecuteProcessCurrentObject(SimpleActionExecuteEventArgs e)
{
if (View is ListView && View.ObjectType == typeof(DomainObject1)) {
return;
}
base.ExecuteProcessCurrentObject(e); }}}
how To Add a Simple Button on Detail View
To add simple button on DetailView
Go in BO Model=>DomainObject2 DetailView=>Items=>Add=>ControlDetailItems and give its ID and Caption
Also set its Property ControlTypeName=DevExpress.XtraEditors.SimpleButton
Now Button is Visible on DetailView you can find this button from DetailView and Fire Event
OR
Go in ModelEditor Code and write the code
How To a Add Simple Button on DetailView
To add simple button on DetailView
Go in BO Model=>DomainObject2 DetailView=>Items=>Add=>ControlDetailItems and give its ID and Caption
Also set its Property ControlTypeName=DevExpress.XtraEditors.SimpleButton
Now Button is Visible on DetailView you can find this button from DetailView and Fire Event
OR
Go in ModelEditor Code and write the code
Fire Event on Button Added on DetailView
if (View is DetailView && View.ObjectTypeInfo.Type == typeof(DomainObject2))
{
DetailView dv = (DetailView)View;
ControlDetailItem pe = (ControlDetailItem)dv.FindItem("B1");
DevExpress.XtraEditors.SimpleButton Button = (DevExpress.XtraEditors.SimpleButton)pe.Control;
Button.Click += new EventHandler(Button_Click);}
How To Find Master Object of ListView
PropertyCollectionSource pcs = (PropertyCollectionSource)LV1.CollectionSource;
DailyAttendenceSheet dcv = pcs.MasterObject as DailyAttendenceSheet;
Here DailyAttendenceSheet is MasterObject means DetailView
Here Lv1 is ListView
Enble Master View of GridView
if (View is ListView && View.Id.Contains("ProfitAndLoss_ListView"))
{
ListView lv = (ListView)View;
GridControl gc = (GridControl)lv.Control;
GridView gv = (GridView)gc.FocusedView;
gv.OptionsView.ShowDetailButtons = true;
gv.OptionsDetail.EnableMasterViewMode = true;
// gv.OptionsDetail.AllowZoomDetail = true;
gv.OptionsDetail.AutoZoomDetail = true;
}
Activate Panel on Class
namespace PanelTesting.Module
{
public partial class PanelViewController : ViewController
{
public PanelViewController()
{
InitializeComponent();
RegisterActions(components);
TargetObjectType = typeof(Panel);
}
protected override void OnActivated()
{
base.OnActivated();
View.ControlsCreated += new EventHandler(View_ControlsCreated);
}
void View_ControlsCreated(object sender, EventArgs e)
{
((System.Windows.Forms.Control)View.Control).HandleCreated += new EventHandler(PanelViewController_HandleCreated);
}
void PanelViewController_HandleCreated(object sender, EventArgs e)
{
LabelControl lbTitle2 = new LabelControl();
lbTitle2.Appearance.BackColor = System.Drawing.Color.Transparent;
lbTitle2.Appearance.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
//lbTitle2.Appearance.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
//lbTitle2.Appearance.Options.UseBackColor = true;
lbTitle2.Appearance.Options.UseFont = true;
//lbTitle2.Appearance.Options.UseForeColor = true;
lbTitle2.Location = new System.Drawing.Point(12, 32);
lbTitle2.Name = "lbTitle2";
lbTitle2.Size = new System.Drawing.Size(183, 20);
lbTitle2.TabIndex = 5;
lbTitle2.Text = "by Cevious Technologies Pvt. Ltd.";
//
// lbTitle1
//
LabelControl lbTitle1 = new LabelControl();
lbTitle1.Appearance.BackColor = System.Drawing.Color.Transparent;
lbTitle1.Appearance.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold);
//lbTitle1.Appearance.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
//lbTitle1.Appearance.Options.UseBackColor = true;
lbTitle1.Appearance.Options.UseFont = true;
//lbTitle1.Appearance.Options.UseForeColor = true;
lbTitle1.Location = new System.Drawing.Point(12, 4);
lbTitle1.Name = "lbTitle1";
lbTitle1.Size = new System.Drawing.Size(104, 20);
lbTitle1.TabIndex = 4;
lbTitle1.Text = "Applicatin Testing";
PanelControl lbCaption = new PanelControl();
lbCaption.Controls.Add(lbTitle2);
lbCaption.Controls.Add(lbTitle1);
lbCaption.Dock = System.Windows.Forms.DockStyle.Top;
lbCaption.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Bold);
//lbCaption.Font2 = new System.Drawing.Font("Tahoma", 11.25F);
lbCaption.Location = new System.Drawing.Point(0, 0);
lbCaption.Name = "lbCaption";
lbCaption.Size = new System.Drawing.Size(828, 60);
lbCaption.TabIndex = 2;
lbCaption.TabStop = false;
lbCaption.SuspendLayout();
((System.Windows.Forms.Control)sender).Parent.Controls.Add(lbCaption);
}
}
Hide Link Button From Associated Class
if (View is ListView && !View.IsRoot && View.ObjectType==typeof(DemoTask)) {
Frame.GetController().LinkObjectAction.Active.SetItemValue("myReason", false);}
Hide Skin Action From Toolbar
namespace WinSolution.Module.Win {
public partial class WindowController1 : WindowController {
public WindowController1() {
InitializeComponent();
RegisterActions(components);
}
protected override void OnActivated() {
base.OnActivated();
Window.GetController().ChooseSkinAction.Active.SetItemValue("myReason", false);}}}
Hide New Button From Lookup
namespace MainDemo.Module.Win.Module {
public partial class ViewController1 : ViewController {
public ViewController1() {
InitializeComponent();
RegisterActions(components);
}
protected override void OnActivated() {
base.OnActivated();
if (View.Id=="Contact_LookupListView") {
Frame.GetController().NewObjectAction.Active.SetItemValue("myReason", false);}}}}
Open ListView on Navigation Click
To do this you have to write a Controller and inherit it with ShowNavigationItemController Now add the code below
protected override void ShowNavigationItem(SingleChoiceActionExecuteEventArgs args)
{
base.ShowNavigationItem(args);
if ((args.SelectedChoiceActionItem != null) && args.SelectedChoiceActionItem.Enabled)
{
if (args.SelectedChoiceActionItem.Id == "Shipment_ListView")
{
ObjectSpace os = Application.CreateObjectSpace();
DevExpress.ExpressApp.ListView lv = Application.CreateListView(os, typeof(DispatchRegister), true); args.ShowViewParameters.CreatedView = lv;
args.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow; args.ShowViewParameters.CreateAllControllers = true;
DialogController dc = new DialogController(); args.ShowViewParameters.Controllers.Add(dc); dc.Accepting += new EventHandler(dc_Accepting);
}
}
}
Now Write Code on Accepting
void dc_Accepting(object sender, DialogControllerAcceptingEventArgs e)
{
ObjectSpace os=Application.CreateObjectSpace ();
DevExpress.ExpressApp.ListView lv = ((DevExpress.ExpressApp.ListView)((WindowController)sender).Window.View);
Shipment sp = null;
CollectionSource cs = new CollectionSource(os, typeof(Shipment));
CollectionSourceBase cs1 = (CollectionSourceBase)lv.CollectionSource;
foreach (DispatchRegister dr in lv.SelectedObjects)
{
sp = new Shipment(os.Session);
sp.BlockNo = dr.DeliveryNumber;
sp.ChallanNo = dr.DistributionChannel;
cs.Collection.Add(os.GetObject (sp));
}
DevExpress.ExpressApp.ListView listView = Application.CreateListView("Shipment_ListView", cs, true); e.ShowViewParameters.CreatedView = listView;
e.ShowViewParameters.TargetWindow = TargetWindow.Default;
}
protected override void ShowNavigationItem(SingleChoiceActionExecuteEventArgs args)
{
base.ShowNavigationItem(args);
if ((args.SelectedChoiceActionItem != null) && args.SelectedChoiceActionItem.Enabled)
{
if (args.SelectedChoiceActionItem.Id == "Shipment_ListView")
{
ObjectSpace os = Application.CreateObjectSpace();
DevExpress.ExpressApp.ListView lv = Application.CreateListView(os, typeof(DispatchRegister), true); args.ShowViewParameters.CreatedView = lv;
args.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow; args.ShowViewParameters.CreateAllControllers = true;
DialogController dc = new DialogController(); args.ShowViewParameters.Controllers.Add(dc); dc.Accepting += new EventHandler
}
}
}
Now Write Code on Accepting
void dc_Accepting(object sender, DialogControllerAcceptingEventArgs e)
{
ObjectSpace os=Application.CreateObjectSpace ();
DevExpress.ExpressApp.ListView lv = ((DevExpress.ExpressApp.ListView)((WindowController)sender).Window.View);
Shipment sp = null;
CollectionSource cs = new CollectionSource(os, typeof(Shipment));
CollectionSourceBase cs1 = (CollectionSourceBase)lv.CollectionSource;
foreach (DispatchRegister dr in lv.SelectedObjects)
{
sp = new Shipment(os.Session);
sp.BlockNo = dr.DeliveryNumber;
sp.ChallanNo = dr.DistributionChannel;
cs.Collection.Add(os.GetObject (sp));
}
DevExpress.ExpressApp.ListView listView = Application.CreateListView("Shipment_ListView", cs, true); e.ShowViewParameters.CreatedView = listView;
e.ShowViewParameters.TargetWindow = TargetWindow.Default;
}
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...
-
CriteriaOperator criteria = new BinaryOperator("Age", 30, BinaryOperatorType.Greater); CriteriaOperator criteria = CriteriaOperato...
-
SortingCollection sc = new SortingCollection(); sc.Add (new SortProperty("field on which you want to sort",DevExpress.Xpo.DB.Sorti...
-
Here ItemName will be Enable/Disable According to IsApplicable Property Assembly: DevExpress.XtraLayout; DevExpress.ExpressApp.Win.Layou...