Category: Devexpress
DEVEXPRESS GRIDVIEW LAYOUT REGISTRY
gridview1.RestoreLayoutFromRegistry("DevExpress\\XtraGrid\\Layouts\\" + this.GetType().Namespace + "\\" + gridview1.Name) ;
gridview1.SaveLayoutToRegistry("DevExpress\\XtraGrid\\Layouts\\" + this.GetType().Namespace + "\\" + gridview1.Name );
C# DEVEXPRESS XTRAGRID KOLON SABITLE MENUSU
private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
{
if (e.MenuType == GridMenuType.Column)
{
GridViewColumnMenu menu = e.Menu as GridViewColumnMenu;
if (menu.Column != null)
{
var myMenu = new DXMenuCheckItem("Sola - Kolon Sabitle/Geri Al", menu.Column.Fixed == FixedStyle.Left, default, new EventHandler(FreezeUnfreezeColumnLeft_Click));
myMenu.Image = global::MYAPP.Properties.Resources.Left; //LEFT ARROW ICON FOR myMenu.Image = Left.png
myMenu.BeginGroup = true;
myMenu.Enabled = true;
myMenu.Tag = menu.Column;
e.Menu.Items.Add(myMenu);
var myMenu2 = new DXMenuCheckItem("Sağa - Kolon Sabitle/Geri Al", menu.Column.Fixed == FixedStyle.Right, default, new EventHandler(FreezeUnfreezeColumnRight_Click));
myMenu2.Image = global::MYAPP.Properties.Resources.Right; //RIGHT ARROW ICON FOR myMenu2.Image = Right.png
myMenu2.BeginGroup = false;
myMenu2.Enabled = true;
myMenu2.Tag = menu.Column;
e.Menu.Items.Add(myMenu2);
}
}
}
private void FreezeUnfreezeColumnLeft_Click(object sender, EventArgs e)
{
DXMenuCheckItem item = sender as DXMenuCheckItem;
GridColumn info = (GridColumn)item.Tag;
if (info is null)
return;
if (info.Fixed == FixedStyle.Left)
{
info.Fixed = FixedStyle.None;
}
else
{
info.Fixed = FixedStyle.Left;
}
}
private void FreezeUnfreezeColumnRight_Click(object sender, EventArgs e)
{
DXMenuCheckItem item = sender as DXMenuCheckItem;
GridColumn info = (GridColumn)item.Tag;
if (info is null)
return;
if (info.Fixed == FixedStyle.Right)
{
info.Fixed = FixedStyle.None;
}
else
{
info.Fixed = FixedStyle.Right;
}
}
C# DEVEXPRESS PIVOTGRIDCONTROL
pivotGridControl1.DataSource = DLL.SQL.SELECT(string.Format("SELECT * FROM MIZANMALZEME WHERE (Cast(Tarih as smalldatetime) between '" + TE_bASLANGICTARIHI.DateTime.ToString("yyyy-MM-dd") + "' and '" + TE_BITISTARIHI.DateTime.ToString("yyyy-MM-dd") + "') AND Isyeri_No IN (" + ISYERI_NRLERI + ")"));
pivotGridControl1.RetrieveFields();
pivotGridControl1.RestoreLayoutFromRegistry(@"Software\RAPOR\FRM_FINANSAL_RAPOR_212+" + pivotGridControl1.Name);
PIVOTBESTFIT();
private void PIVOTBESTFIT()
{
try
{
pivotGridControl1.BestFit();
int i = 0;
foreach (PivotGridField item in pivotGridControl1.Fields)
{
item.BestFit();
}
}
catch { }
}
C# Devexpress Xaf Notları
Eğer BusinnesObjects Class XPObject üzerinden inherit oluyorsa (varsayılan BaseObject) Detail viewde oid alanı gelmekte. Bunu gizlemek için Module\Module.cs eklenmeli;
typesInfo.FindTypeInfo(typeof(XPObject)).KeyMember.AddAttribute(new BrowsableAttribute(false));

OnSaving()de otomatik kod ataması için DistributedIdGeneratorHelper.Generate kullanımı;


C# Devexpress xaf snippets


<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxaf</Title>
<Shortcut>propxaf</Shortcut>
<Description>Insert a property in XPO</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Property type</ToolTip>
<Default>string</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property name</ToolTip>
<Default>Name</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
private $type$ _$property$;
public $type$ $property$
{
get { return _$property$;}
set { SetPropertyValue<$type$>(nameof($property$), ref _$property$, value); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
propxafCollection.snippet:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxafCollection</Title>
<Shortcut>propxafCollection</Shortcut>
<Description>Insert a collection in XPO</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Remote Property type</ToolTip>
<Default>DomainObject</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Collection Property name</ToolTip>
<Default>MyProperty</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
[Association]
public XPCollection<$type$> $property$ {
get { return GetCollection<$type$>(nameof($property$)); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
propxafCollectionAggregated.snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxafCollectionAggregated</Title>
<Shortcut>propxafCollectionAggregated</Shortcut>
<Description>Insert an aggregated collection (No link/unlink) in XPO</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Remote Property Type</ToolTip>
<Default>DomainObject</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Collection Property Name</ToolTip>
<Default>CollectionName</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
[DevExpress.Xpo.Aggregated, Association]
public XPCollection<$type$> $property$ {
get { return GetCollection<$type$>(nameof($property$)); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
propxafCust.snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxafCust</Title>
<Shortcut>propxafCust</Shortcut>
<Description>Insert a custom object with default Name property</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>class</ID>
<ToolTip>Class Name</ToolTip>
<Default>CustomObject</Default>
</Literal>
<Literal>
<ID>classtype</ID>
<ToolTip>XPO Base Object Type (BaseObject, XPCustomObject, XPLiteObject, etc.)</ToolTip>
<Default>BaseObject</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
[DefaultProperty("Name")]
public class $class$ : $classtype$
{
public $class$(Session session) : base(session) { }
private string _Name;
public string Name
{
get { return _Name; }
set { SetPropertyValue<string>("Name", ref _Name, value); }
}
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
propxafOne.snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxafOne</Title>
<Shortcut>propxafOne</Shortcut>
<Description>Insert a property with a One to Many relationship in XPO</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Property Type</ToolTip>
<Default>DomainObject</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property Name</ToolTip>
<Default>MyProperty</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
private $type$ _$property$;
[Association]
public $type$ $property$
{
get { return _$property$;}
set { SetPropertyValue<$type$>(nameof($property$), ref _$property$, value); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
propxafPersistentAlias.snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>propxafPersistentAlias</Title>
<Shortcut>propxafPersistentAlias</Shortcut>
<Description>Insert a persistent alias property in XPO</Description>
<Author>Llamachant Technology Ltd.</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>expression</ID>
<ToolTip>Alias Expression</ToolTip>
<Default></Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Property Type</ToolTip>
<Default>string</Default>
</Literal>
<Literal>
<ID>property</ID>
<ToolTip>Property Name</ToolTip>
<Default>Name</Default>
</Literal>
<Literal>
<ID>converttype</ID>
<ToolTip>Convert to Type</ToolTip>
<Default>Int32</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[
[PersistentAlias("$expression$")]
public $type$ $property$
{
get { return Convert.To$converttype$(EvaluateAlias(nameof($property$))); }
}
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
C# DEVEXPRESS XTRAINPUTBOX
BAZEN FORM YARATMADAN BURDAN DEĞER ALINABİLİR



string reason = XtraInputBox.Show("Açıklama", "İptal Açıklamasını Giriniz", "");
if (string.IsNullOrEmpty(reason) || string.IsNullOrWhiteSpace(reason) || reason == "")
{
MessageBox.Show("İptal İşleminde Açıklama Girmek Zorunludur.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//handle cancel
private void PrintBarcodeDirectClick(object sender, EventArgs e)
{
XtraInputBoxArgs xtraInputBoxArgs = new XtraInputBoxArgs();
xtraInputBoxArgs.Caption = "Miktar";
xtraInputBoxArgs.Prompt = "Yazılacak Miktar Giriniz";
xtraInputBoxArgs.DefaultButtonIndex = 0;
xtraInputBoxArgs.Showing += XtraInputBoxArgs_Showing;
xtraInputBoxArgs.DefaultResponse = "1";
SpinEdit editor = new SpinEdit();
editor.Properties.IsFloatValue = false;
editor.Properties.Mask.EditMask = "N00";
editor.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
editor.Properties.Mask.UseMaskAsDisplayFormat = true;
xtraInputBoxArgs.Editor = editor;
var qty = XtraInputBox.Show(xtraInputBoxArgs);
var result = qty?.ToString();
MessageBox.Show(result);
}
private void XtraInputBoxArgs_Showing(object sender, XtraMessageShowingArgs e)
{
e.Form.Text = "Miktar";
}
DEVEXPRESS XTRAGRID GROUP SUMMARY TO NEW GROUP SUMMARY


private void GRV_FISICERIGI_CustomSummaryCalculate(object sender, DevExpress.Data.CustomSummaryEventArgs e) {
if (!e.IsGroupSummary) return;
if (e.SummaryProcess != CustomSummaryProcess.Finalize) return;
var item = (GridSummaryItem)e.Item;
switch (item.Tag) {
case "G_DMHS":
if (e.IsGroupSummary) {
var CALISMADURUMU = int.Parse(GRV_FISICERIGI.GetGroupSummaryValue(e.GroupRowHandle, (GridGroupSummaryItem)GRV_FISICERIGI.GroupSummary["G_CALISMADURUMU"]).ToString());
e.TotalValue = (CALISMADURUMU - int.Parse(TE_HAFTA.Text)) * 8;
}
break;
case "G_EMEESMADMHS":
if (e.IsGroupSummary) {
var EKMESAI = TimeSpan.Parse(GRV_FISICERIGI.GetGroupSummaryValue(e.GroupRowHandle, (GridGroupSummaryItem)GRV_FISICERIGI.GroupSummary["G_EKMESAI"]).ToString());
var EKSIMESAI = TimeSpan.Parse(GRV_FISICERIGI.GetGroupSummaryValue(e.GroupRowHandle, (GridGroupSummaryItem)GRV_FISICERIGI.GroupSummary["G_EKSIMESAI"]).ToString());
var CALISMADURUMU = int.Parse(GRV_FISICERIGI.GetGroupSummaryValue(e.GroupRowHandle, (GridGroupSummaryItem)GRV_FISICERIGI.GroupSummary["G_DMHS"]).ToString());
e.TotalValue = (EKMESAI - EKSIMESAI) + TimeSpan.FromHours(CALISMADURUMU);
}
break;
case "G_EMEESMADMHSB8":
if (e.IsGroupSummary) {
var G_EMEESMADMHS = TimeSpan.Parse(GRV_FISICERIGI.GetGroupSummaryValue(e.GroupRowHandle, (GridGroupSummaryItem)GRV_FISICERIGI.GroupSummary["G_EMEESMADMHS"]).ToString());
e.TotalValue = (G_EMEESMADMHS.Hours + G_EMEESMADMHS.Minutes / 100.0 + G_EMEESMADMHS.Seconds / 10000.0) * (G_EMEESMADMHS > TimeSpan.Zero ? 1 : -1) / 8;
}
break;
}
}
DEVEXPRESS GRID LOAD SAVE FROM REGISTRY VERSION
string version = "";
public FRM_MALZEME_FIYATLARI() {
InitializeComponent();
version = "v" + Assembly.GetEntryAssembly().GetName().Version;
DX.DXGRID_LOADLAYOUTFROM_REGISTIRY(GRC_MALZEMEFIYATLARI, GetType().Namespace, "SATISFIYATI_OTOMASYONU_SERVICE__FRM_MALZEMELER_FIYATLARI" + version);
DX.DXGRID_SAVELAYOUTTO_REGISTIRY(GRC_MALZEMEFIYATLARI, GetType().Namespace, "SATISFIYATI_OTOMASYONU_SERVICE__FRM_MALZEMELER_FIYATLARI" + version);
}