Category Archives: WinForm

Use Currency Format For Different Cultures c#

            double value = 5623345.6789;

            //For Default System Culture

            // By default, single letter C displays currency upto two decimal digits

            Console.WriteLine(value.ToString(“C”, CultureInfo.CurrentCulture));

            // C2 displays currency upto two digits

            Console.WriteLine(value.ToString(“C2”, CultureInfo.CurrentCulture));

            // C3 displays currency upto three digits

            Console.WriteLine(value.ToString(“C3”, CultureInfo.CurrentCulture));

            // C4 displays currency upto four digits

            Console.WriteLine(value.ToString(“C4”, CultureInfo.CurrentCulture));

            // C5 displays currency upto five digits

            Console.WriteLine(value.ToString(“C5”, CultureInfo.CurrentCulture));

            //For Japan Format

            Console.WriteLine(“\n——— Dispalying Currency for Japan —————\n”);

            Console.WriteLine(value.ToString(“C”, CultureInfo.CreateSpecificCulture(“ja-JP”)));

            //For Denmark Format

            Console.WriteLine(“\n——— Dispalying Currency for Denmark —————\n”);

            Console.WriteLine(value.ToString(“C”,       CultureInfo.CreateSpecificCulture(“da-DK”)));

           if Possible same program use with Multiple currencies and you want to fix currency not dependent on Culture then use this

      lblCustomerPayment.Text = string.Format(new CultureInfo(“en-US”, true), “{0:C2}”, value );

For more Help to Explore this below link


Leave a comment

Posted by on October 18, 2018 in ASP Dot Net C#, WinForm


devexpress multiple gridview export to excel in Single File winforms

After two much searching of this solution to export multiple gridview data to single Excel file with separate Sheet of Excel.

Then i find this solution which resolve my problem. this is 100% tested and use in my project . after that i share with you in both language c# and


 Solution :: Vb.Net

Imports DevExpress.XtraPrinting
Imports DevExpress.XtraPrintingLinks


Public Sub MultiFileExportToExcel()

Using saveDialog = New SaveFileDialog()
saveDialog.Filter = “Excel (.xlsx)|*.xlsx”
If saveDialog.ShowDialog() = DialogResult.OK Then
Dim printingSystem = New PrintingSystemBase()
Dim compositeLink = New CompositeLinkBase()
compositeLink.PrintingSystemBase = printingSystem

Dim link1 = New PrintableComponentLinkBase()
link1.Component = grid1
Dim link2 = New PrintableComponentLinkBase()
link2.Component = grid2


Dim options = New XlsxExportOptions()
options.ExportMode = XlsxExportMode.SingleFilePageByPage

compositeLink.ExportToXlsx(saveDialog.FileName, options)
End If
End Using
End Sub


Solution ::  C#

using DevExpress.XtraPrinting
using DevExpress.XtraPrintingLinks

public void exportToExcel()
using (var saveDialog = new SaveFileDialog())
saveDialog.Filter = “Excel (.xlsx)|*.xlsx”;
if (saveDialog.ShowDialog() == DialogResult.OK)
var printingSystem = new PrintingSystemBase();
var compositeLink = new CompositeLinkBase();
compositeLink.PrintingSystemBase = printingSystem;

var link1 = new PrintableComponentLinkBase();
link1.Component = grid1;
var link2 = new PrintableComponentLinkBase();
link2.Component = grid2;


var options = new XlsxExportOptions();
options.ExportMode = XlsxExportMode.SingleFilePageByPage;

compositeLink.ExportToXlsx(saveDialog.FileName, options);


Reference url;

Leave a comment

Posted by on April 22, 2015 in Vb.Net, WinForm


Tags: ,

Devexpress Gridview RepositoryItemCheckEdit changes immediatelly

If you have a Gridview with the first column edited with an RepositoryItemCheckEdit and with the datasource an runtime created datatable.
What I want to obtain and I not succeeded yet is to count the rows from the datatable with check on the first column and put the result in a labelimmediatelly after user changes check state of repository.

but if you check/Uncheck checkbox   RepositoryItemCheckEdit  Event then your Count not match with Gridview Checkbox.if you use different event of Gridview . the solution of your problem is..

Private Sub repositoryItemCheckEdit1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
End Sub

The PostEditor method posts the edited value to the underlying source. I’ve attached a sample demonstrating how it works. Please test it and let us know your result.

the CountChecked method as follows:

Private Sub CountChecked()
    Dim checkedCount As Integer = 0
    Dim dt As DataTable = CType(gridControl1.DataSource, DataTable)
    For i As Integer = 0 To dt.Rows.Count - 1
        If CBool(dt.Rows(i)("Check")) Then
            checkedCount += 1
        End If
    Next i
    labelControl1.Text = "Checked: " & checkedCount.ToString()
End Sub

Reference :







1 Comment

Posted by on July 4, 2014 in WinForm


Tags: ,

Disable Textbox Paste Option in Winform

If you want to disable paste option on text box in Winform Application then this code very helpful for you.

Private Sub txtbarcode_KeyDown(sender As Object, e As KeyEventArgs) Handles txtArabicName.KeyDown

If e.Control And e.KeyValue = 86 Then
e.Handled = True
e.SuppressKeyPress = True
End If
End Sub


private void txtbarcode_KeyDown(object sender, KeyEventArgs e)
	if (e.Control & e.KeyValue == 86) {
		e.Handled = true;
		e.SuppressKeyPress = true;

Leave a comment

Posted by on May 27, 2014 in WinForm


Tags: , ,

How to disable the default Context Menu devexpress

If you want to Hide context menu on specific TextBoxt (Devexpress) Control then use this following Code,Write this code on Form Load Event


ContextMenu emptyMenu = new ContextMenu();


txtBardcode.Properties.ContextMenu = emptyMenu;


Dim emptyMenu As New ContextMenu()


txtBardcode.Properties.ContextMenu = emptyMenu





Leave a comment

Posted by on May 27, 2014 in WinForm


Tags: , ,

Could not load file or assembly ‘file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll’ or one of its dependencies. The system cannot find the file specified.

This Error give this message…..

This stuff basically happens, if you have correct setup of SBO (I wish you so:)), that between different components of your SBO SDK there are assemblies with different .NET version. Check if you have someold version of SAP BO SDK installed on your machine too. Hope this helps.



add this to your .config file (usually app.config)
<startup useLegacyV2RuntimeActivationPolicy=”true”>
<supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.0″/>





Leave a comment

Posted by on January 17, 2014 in Crystal Report, WinForm


devexpress TextEdit: Automatic validation

if you want to validate E-mail runtime using devexpress TextEdit control. you use this mask for both web & winform.


Mask : [a-zA-Z0-9.-]+@[a-zA-Z0-9-]+\.[A-Za-z]{2,6}

I have added a Textbox like this:
<dxe:TextEdit EditValue=”{Binding Email}” MaskType=”RegEx” Mask=”[a-zA-Z0-9.-]+@[a-zA-Z0-9-]+\.[A-Za-z]{2,6}” />

As you can see it is using a regex to validate email adresses.
The mask is very nice, however i can easily tab out of the field resulting in invalid data being bound to my model.

Shouldnt it automatically Validate the mask on losing focus


Email Validate


Leave a comment

Posted by on December 16, 2013 in WinForm