Click Here to Install Silverlight*
Middle EastChange|All Microsoft Sites

Visual Studio .NET® With Arabic Language Support



Visual Studio .NET is a complete set of development tools for building ASP.NET Web applications, XML Web Services, desktop applications, and mobile applications. Visual Studio .NET provides the same integrated development environment (IDE) for Visual Basic .NET, Visual C++ .NET, and Visual C# .NET, which allows them to share tools and facilitates in the creation of mixed-language solutions. In addition, these languages leverage the functionality of the .NET Framework, which provides access to key technologies that simplify the development of ASP.NET Web applications and XML Web services. The Microsoft® .NET Framework transforms application development with a fully managed, protected, and feature-rich application execution environment; simplified development and deployment; and seamless integration with a wide variety of languages.

The following sections discuss and demonstrate to what extent the .NET Framework and Visual Studio .NET support Arabic, including information about the features and limitations of Arabic support.


As you install Visual Studio .NET, you will have the opportunity to choose among several different installation and setup options. Visual Studio .NET setup provides two specialized installations modes, Administrator and Remote components. The following section explains the most popular and simple installation scenario and shows how Visual Studio .NET installation may support Arabic. The system and user locals must be set to an Arabic locale to be able to enter and display text correctly.

To install Visual Studio .NET:

  1. Close all open applications.
  2. Insert the disk labeled Visual Studio .NET CD1 or DVD.

Autorun starts Setup.exe. If Autorun is disabled, run Setup.exe from the root of the installation CD or DVD.
When startup starts, the following dialog box appears:

Select step 1 to update system component. If a component update is not required, this option is not available.

Select step 2 to start installing Visual Studio .NET. The Start Page appears with the End-User License Agreement and prompts you to supply your name. You can type a name in Arabic.

The Options Page appears to select the languages and components that you want to install and to specify the path of the installation. You can enter Arabic text for folders names.

Press Install Now! to run the installation process to completion.

Note: If you are running an anti-virus program while setup runs, warnings may be displayed because setup runs scripts that access the file system object. It is safe to allow the setup to continue.

Visual Studio .NET IDE

The following topics explain the main elements of the Visual Studio .NET integrated development environment (IDE) and how they support Arabic.

Creating New Projects

The IDE enables developers to create new projects with different languages and templates. A project template creates the initial files, references, code framework, property settings, and tasks appropriate for the selected project.
Visual Studio .NET is based on Unicode, so you can use Arabic for your project name, using any Arabic characters including Kashida and Diacritics. In addition, the path of the project can contain Arabic as part of folder names, as illustrated in Figure 1.

Figure 1

Solution Explorer

Solution Explorer provides you with an organized view of your projects and their files as well as ready access to the commands that pertain to them. Solution Explorer is able to display the names of the solution, project or projects, and files in Arabic, as shown in Figure 2.

Figure 2

Code and Text Editor

The code and text editor allows you to enter, display, and edit code or text. It is referred to as either the text editor or the code editor, based on its content.
Visual Studio .NET editor supports entering, displaying and editing Arabic text, but it does not support right-to-left (RTL) reading order because the editor was designed for English support. As result, manipulating Arabic text or mixed text (English and Arabic) doesn't work smoothly. However, you are free to use Arabic text in your code and comments in these ways:

  • Code: use Arabic into the code to name classes, functions, variables, properties and so on. If you type Arabic into your code, you should know that Visual Studio .NET deals with text as binary. In other words, if you have named a variable in Arabic and the variable name includes Kashida, then you must refer to the variable as it is, with Kashida, or the compiler will generate errors.
  • Comments: use Arabic text in comments to explain your code. You can also, use the comment builder tool.
  • Text: you may use Arabic text to assign strings but for localization purposes it is advised to place all your Arabic text in your project resource.

The Visual Studio .NET compilers, mainly VB .NET and C# .NET, support any language into the code, as well as English, without generating any errors. Figure 3. illustrates the use of Arabic in your code.

Figure 3

Managing Files with Encoding

One of the most important enhancements in the Visual Studio IDE for international support is the ability to save and display your code in a particular language and on a particular platform and to associate a particular character encoding with a file.

Opening Files:
You can choose the editor you want to use to edit the file. The list of editors available when you are opening the file depends upon the type of file you are attempting to open or create. Figure 4.and 5

Figure 4

Figure 5

Saving Files:
You can save your code with a Unicode encoding or a different code page to support various languages, such as Arabic. You can associate a particular character encoding with a file to facilitate the display of your code in that language, as well as a line ending type to support a particular operating system. Note that, some characters cannot be used in file names unless they are saved with Unicode encoding. See Figure 6.

Figure 6

Properties Window

Use the Properties window to view and change the design-time properties and events of selected objects in the designers. You can also use the Properties window to edit and view file, project, and solution properties. The Properties window is available from the View menu. You can enter Arabic text in the Properties window as a property value - for example the Text property of a Button control. To enter text in RTL reading order in the Properties window press Ctrl + right Shift (this may vary according to your Text Services and Input Language – Key Sequence setting in the control panel). Figure 7 shows how to enter Arabic text with RTL reading order in the Properties window.

Figure 7

Server Explorer

Server Explorer is the server management console for Visual Studio .NET. You can use Server Explorer to view and manipulate data links, database connections, and system resources on any server to which you have network access.
The following figure demonstrates the capability of Server Explorer to explore a database whose elements are named in Arabic.

Clipboard Ring

The Clipboard Ring tab of the Toolbox stores the last twelve items added to the system Clipboard using the Cut or Copy commands. These items can be dragged from the Clipboard Ring tab and dropped onto the active editing or design surface. The Clipboard Ring supports Arabic as well as English, as shown in Figure 8

Figure 8

The .NET Framework and Class Library

The .NET Framework has two main components: the common language runtime and the .NET Framework class library.

Common Language Runtime:
The common language runtime is the foundation of the .NET Framework. The common language runtime loads and runs code written in any language that targets the runtime. Code that targets the runtime is known as managed code, while code that does not target the runtime is known as unmanaged code. This paper's main emphasis would be the managed code.
The common language runtime provides core services such as memory management, thread management, and remote accessing, while also enforcing strict safety and accuracy of the code. In addition, the runtime provides code access security that allows developers to specify permissions to run the code. In fact, the concept of code management is a fundamental principle of the runtime.

.NET Framework Class Library:
The .NET Framework class library is a collection of classes that can be called from any .NET enabled programming language. The class library is object oriented, providing types from which your own managed code can derive functionality. This not only makes the .NET Framework types easy to use, but also reduces the time associated with learning new code. In addition, third-party components can integrate seamlessly with the classes in the .NET Framework.
You can use the .NET Framework to develop the following types of applications and services:

  • Console applications.
  • Scripted or hosted applications.
  • Windows GUI applications (Windows Forms).
  • ASP.NET applications.
  • XML Web services.
  • Windows 2000 and Windows NT services.

Console Applications

Console applications are designed typically without a graphical user interface and compile into a stand-alone executable file. A console application is run from the command line with input and output information being exchanged between the command prompt and the running application.

The Console applications do not support Arabic Text for input and output due to a limitation in the operating system console support.

Windows Forms Applications

Windows applications created with .NET framework offer you many benefits. You can access operating system services and take advantage of other benefits provided by your user's computing environment. You can access data using ADO .NET. GDI+ allows you to do advanced drawing and painting within your forms. Your Windows applications can make calls to methods exposed through XML Web services. The following topics explain how Windows Forms applications support Arabic.

Windows Forms

Windows forms can be standard windows, multiple document interface (MDI) windows, dialog boxes, or display surfaces for graphical routines. The easiest way to define the user interface for a form is to place controls on its surface. Forms are objects that expose properties which define their appearance, methods which define their behavior, and events which define their interaction with the user.

Right To Left:
Windows Forms are controls, because they inherit from the Control class. This class has a key property for Arabic support: the RightToLeft property, which specifies whether the text is displayed from right to left, such as when using Arabic fonts. The form itself supports the RightToLeft property, as do all your controls.

The RightToLeft property takes one of the following values:

Value Description
Inherit The direction the text is displayed is inherited from the parent control.
No The text is displayed from left to right. This is the default.
Yes The text is displayed from right to left.

The effect of this property can differ slightly effect from one control to another, as described later in the section Windows Forms Controls. In the Form object, w hen you set the RightToLeft property to Yes, text displayed in the form's title bar is right-aligned with RTL reading order. However, the icon and control box retain their left and right alignment respectively, as shown in Figure 9

Figure 9

What about design time? The Windows Forms Designer reflects the effects of the RightToLeft property on controls. For example, when you set the RightToLeft property of the form to Yes, it automatically updates the display of the form in the designer, so that the form's caption appears in the title bar right-aligned, as at run time.

You might ask, "What's new about that? Visual Basic 6.0 forms support the RightToLeft property. This is not full Arabic support — we need Windows Forms to support mirroring! " The answer is: "Yes, but …" Windows Forms don't support mirroring directly, as they do the RightToLeft property. But Windows Forms do give developers the capability to customize the appearance and functionality of the controls through inheritance. For details, see the next section, Windows Forms Inheritance.

Windows Forms Inheritance

In some occasions, you may want to create a basic form with settings and properties such as a watermark or a certain control layout that you will then use again within a project. Each new form may contain modifications to the original form template. The solution is to use Windows Forms inheritance, which is a strong feature offered with the .NET Framework Class library. For example, using inheritance, you can build your own mirrored form by inheriting from the System.Windows.Forms.Form class and changing its window style. For more details, see Developing Arabic Windows Forms Controls later in this paper.

Message Boxes

The MessageBox class represents the message box, it displays a message box that can contain text, buttons and symbols that inform and instruct the user. The MessageBox class fully supports Arabic features including RTL reading order and mirroring as shown in Figure 10

Figure 10

The Show method of the MessageBox class displays the message box. It takes constant defined in the MessageBoxOptions enumeration as parameter. These include RightAlign and RtlReading both of which enable the message box to display Arabic.

The following code illustrates how to display an Arabic message box:
[Visual Basic]
MessageBox.Show("إختبار مربع الحوار مع اللغة العربية ...", "مربع الحوار", MessageBoxButtons.OK,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading Or


  • RightAlign: This option allows the text to be right-aligned only, but does not enforce RTL reading order or mirroring in the message box.
  • RtlReading: This option is responsible of ensuring that the message box text is displayed with right to left reading order with mirroring.

Note You can not translate (localize) the caption of the message box buttons like Ok or Cancel. These depend on the windows system locale and will therefore appear as "Ok" in English Windows and موافق on Arabic localized windows irrespective of your application.


The common language runtime implemented the Windows graphics design interface (GDI) called GDI+. GDI+ allows you to create graphics, draw text, and manipulate graphical images as objects. GDI+ is designed to offer performance as well as ease of use. You can use GDI+ to render graphical images on Windows Forms and controls. Although you cannot use GDI+ directly on Web Forms, you can display graphical images through the Image Web Server control. GDI+ is now the only way to use graphics in the .NET framework.

Graphics Class:
The System.Drawing namespace provides access to GDI+ basic graphics functionality. The Graphics class represents a GDI+ drawing surface, and is the object that is used to create graphical images. Before you can draw lines and shapes, render text, or display and manipulate images with GDI+, you need to create a Graphics object.
There are several ways to create the graphics object. The common way is to receive a reference to a graphics object as part of the PaintEventArgs in the Paint event of a form or control. This is usually how you obtain a reference to a graphics object when creating painting code for a control, for more details see GDI+ Graphics in MSDN. This technique is used in the code sample below.

How GDI+ Support Arabic?
GDI+ supports Arabic text manipulation including print text with RTL reading order for both output devices, Screen and Printer. The Graphics.DrawString method draws the specified text string at a designated x, y location or rectangle (according to its overloading), with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object. The StringFormat object includes text layout information such as text reading order.

Therefore, you can easily move the origin of the graphics object to be Right-Top, instead of Left-Top, to print out the Arabic text in the designated location on the screen smoothly, without having to calculate locations explicit. The following steps explain how to do this:

  • Set the size of the rectangle, which specifies the printing area, to the size of the whole client area.
  • Set the StringFormat.Flags property to DirectionRightToLeft.
  • Call the Graphics.DrwawString method, passing it the rectangle and StringFormat objects.

The following shows an example of this technique:

[Visual Basic]
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  'Create string to draw. It is advisable to place all your strings in resource files
  Dim drawString As String = "أختبار الرسم"
  'Create font and brush.   Dim drawFont As New Font("Arial", 16)
  Dim drawBrush As New SolidBrush(Color.Black)
  'Create rectangle with size of the client area.
  Dim rec As New RectangleF(0, 0, Me.ClientSize.Width, ClientSize.Height)
  'Set format of string.
  Dim drawFormat As New StringFormat()
  drawFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft
  'Draw string to screen.
  e.Graphics.DrawString(drawString, drawFont, drawBrush, rec, drawFormat)
End Sub

You can use the same technique to print out text on the printer. The only things that will differ are the events you need to handle, for example, the PrintPage event.

Windows Forms Controls

Windows Forms controls are reusable components that encapsulate user interface functionality and are used in client-side Windows applications. Windows Forms provide many ready-to-use controls, in addition to the main infrastructure for developing your own controls.

The Control class includes RightToLeft property, which specifies whether the text appears from right to left. All Windows Forms controls that inherit from Control class support RightToLeft property, as illustrated in figure 11.
When setting the RightToLeft property, the TextAlign property behaves in a different manner. If you enforce right alignment it would be displayed to the left and vice versa because the TextAlign property is based on the near and far coordinates rather than absolute left or right. As we discussed earlier this property may have different effect from one control to another. The table below (Table 1) lists all the controls and how the RightToLeft property may affect them. When the RightToLeft property value is set to RightToLeft.Yes, the horizontal alignment of the control's elements is reversed, yet the elements' alignment values are unchanged. For example, in a TextBox control with the TextAlign property value of HorizontalAlignment.Left, text is displayed right-aligned, but the property value remains HorizontalAlignment.Left. However, if the RightToLeft property value is set to RightToLeft.Yes while the TextAlign property is set to HorizontalAlignment.Right, the text is displayed left-aligned.

Windows Forms component hierarchy

Figure 11

As you know, Arabic controls are laid out from right to left. Visual Studio .NET supports Arabic controls through the RightToLeft property of the controls. However, the RightToLeft property is not sufficient for some controls to be fully Arabic-aware. For example, suppose you have a Treeview control and want to use it in an Arabic application. When you set the RightToLeft property to Yes, only the reading order of the Treeview control will be set to RTL, while the tree and its nodes stay left aligned. The solution is to mirror the Treeview control, so that the tree and its nodes will be right aligned.
Windows Forms controls don't have a property named mirror. Instead, you create your own controls to be displayed as you need. You can develop your own RTLTreeview control, for example, which inherits from the Treeview control and changes its style to be mirrored. For more details, see Developing Arabic Windows Forms Controls later in this paper.

The following table explains how the RightToLeft property affects on the Windows Forms Controls and which of them need to be mirrored.

Control/Component RightToLeft effect Require Mirroring
Button Sets the RTL reading order No
CheckBox The check box is displayed on the right side of the text. No
CheckedListBox All the check boxes are displayed on the right side of the text. No
ColorDialog Not affected, depends on the language of the operating system. No
ComboBox Items in combo box control are right aligned No
ContextMenu Appears right aligned with RTL reading order No
DataGrid Appears right aligned with RTL reading order No
DateTimePicker Not affected, depends on the language of the operating system. No
DomainUpDown Left aligns the up and down buttons No
ErrorProvider Not supported No
FontDialog Depends on the language of the operating system. No
GroupBox The caption of the GroupBox displayed right aligned and it allows all the contained controls to inherit this property. No
VScrollBar displayed on the left side rather than right side of scrollable controls No
HScrollBar start with the scroll box (thumb) right-aligned No
ImageList Not Required No
Label Displayed right-aligned. No
LinkLabel Displayed right-aligned. No
ListBox Items in list box control are right aligned. No
ListView Sets the reading order to RTL, while the elements stay aligned to left. Yes
MainMenu Displayed right-aligned with RTL reading order, during run-time only and not in design-time. No
MonthCalendar Not affected, depends on the language of the operating system. No
NotifyIcon Not supported No
NumericUpDown Up and down buttons are left-aligned. No
OpenFileDialog Not affected, depends on the language of the operating system. No
PageSetupDialog Not affected, depends on the language of the operating system. No
Panel Allows all the contained controls to inherit this property. Yes
PictureBox Not supported No
PrintDialog Not affected, depends on the language of the operating system. No
PrintDocument The vertical scroll bar become left-aligned and the horizontal scroll bar start from left. No
PrintPreview Not affect by this property. No
PrintPreviewDialog Text displayed in the title bar of a Form is right-aligned No
ProgressBar Not affect by this property. Yes
RadioButton The radio button displayed on the right side of the text. No
RichTextBox Control elements that include text are displayed from right to left. with RTL reading order No
SaveFileDialog Not affected, depends on the language of the operating system. No
Splitter Not supported Yes
StatusBar The text in the panels aligned to right with RTL reading. Yes
TabControl Not affect by this property. Yes
TextBox Displays text from right to left with RTL reading order. No
Timer Not required. No
ToolBar Not affect by this property. Yes
ToolTip Sets the RTL reading order. No
TrackBar The scroll or track starts from right. No
TreeView Sets the RTL reading order only Yes

Table 1: Explains how the RightToLeft property affects on the Windows Forms controls and which of them need mirroring

Developing Arabic Windows Forms Controls

In this section we will explain how to create mirrored Windows Forms controls that support Arabic. In general, the following are common scenarios for developing Windows Forms controls

  • Combining existing controls to author a composite control.
    To author a composite control, derive from System.Windows.Forms.UserControl. The base class UserControl provides keyboard routing for child controls and enables child controls to work as a group.
  • Extending an existing control to customize it or to add to its functionality. You can customize any Windows Forms control by deriving from it and overriding or adding properties, methods, and events.
  • Authoring a control that does not combine or extend an existing control.

In this scenario, derive from the base class System.Windows.Forms.Control. You can add as well as override properties, methods, and events of the base class.

Using the second scenario, you can create a new class that inherits from one of the controls that you want to mirror. While the control is being created you can mirror the control by setting the style of the control using some Win32 window styles that are not provided by the Windows Forms namespace. You can override the CreateParams property of the Control class, which gives you the ability to set the desired styles while the control is being created.

The following two examples explain how to develop mirrored Windows form and Treeview controls. The examples use two window styles:

  • WS_EX_LAYOUTRTL: Creates a window whose horizontal origin is on the right edge. Increasing horizontal values, advances to the left.
  • WS_EX_NOINHERITLAYOUT: A window created with this style does not pass its window layout to its child windows.

Mirrored Treeview control

[Visual Basic]
Imports System.ComponentModel
Public class RTLTreeView
'Inherits from the standard TreeView control
Inherits System.Windows.Forms.TreeView
'Define your style
Const WS_EX_LAYOUTRTL = &H400000
Private _RTL As Boolean = False
'Mirrored property to test the RTL order
Description ("Change to the right-to-left layout."),_
DefaultValue(False),Localizable (True), Category("Appearance")>
Public Property Mirrored() As Boolean
    Return _RTL
  End Get
  Set(ByVal Value As Boolean)
    'Set the new value if it changed
    If _RTL <> Value Then
      _RTL = Value
    End If
  End Set
End Property

Protected Overrides ReadOnly Property CreateParams()As
    'Retrieve the CreateParams class to change the style
    Dim CP As System.Windows.Forms.CreateParams
    CP = New System.Windows.Forms.CreateParams()
    CP = MyBase.CreateParams
      'If the control needs RTL add these styles
      If Mirrored Then
        CP.ExStyle = CP.ExStyle Or WS_EX_LAYOUTRTL
      End If
      Return CP
    End Get
  End Property
End Class

Mirrored Windows Form
The following example differs slightly from the previous one in that the style is set to WS_EX_NOINHERITLAYOUT. By having the "no inherit" layout flag, you ensure that the controls on the forms will not get mirrored.

[Visual Basic]
Public Class RTLForm
      If bMirror Then
          cp.ExStyle = cp.ExStyle Or & H400000 Or &H100000
      End If
End Class

Note These window styles are defined in the header file winuser.h as:
#define WS_EX_LAYOUTRTL       0x00400000L       Right to Left Layout
#define WS_EX_NOINHERITLAYOUT       0x00100000L       Do not inherit the layout

However, this solution is not applicable to all controls that may require mirroring. Some classes are marked as not inheritable so, we can not extend these controls. For example, the Progressbar and Imagelist controls are not inheritable and therefore can't be customized to be mirrored using this technique.

Common Dialogs

The common dialog boxes are part of the operating system. Thus, you can't change their user interface language because they depend on the language of the operating system. For example, the interface of Open Dialog will be RTL when displayed in Arabic on Arabic-localized Windows, while it will be LTR when displayed in English on English Windows.

Building Arabic Assemblies - Meta Data

Metadata is binary information describing your program that is stored either in a common language runtime portable executable (PE) file or in memory. When you compile your code into a PE file, metadata is inserted into one portion of the file, while your code is converted to Microsoft intermediate language (MSIL) and inserted into another portion of the file. Every type and member defined and referenced in a module or assembly is described within metadata. When code is executed, the runtime loads metadata into memory and references it to discover information about your code's classes, members, inheritance, and so on.
Metadata describes every type and member defined in your code in a language-neutral fashion, , which makes it possible to use Arabic. Metadata stores the following information:

Description of the assembly.

  • Identity (name, version, culture, public key).
  • The types that are exported.
  • Other assemblies that this assembly depends on.
  • Security permissions needed to run.

Description of types.
  • Name, visibility, base class, and interfaces implemented.
  • Members (methods, fields, properties, events, nested types).

  • Attributes, which includes additional descriptive elements that modify types and members.

You can use Arabic in the metadata to describe your assemblies, types, and attributes, and they will be retrieved successfully. The following example uses Arabic text with the Description attribute to describe Class1, and then retrieves this description in the constructor.

[Description("هذا النموذج يقوم بإجراء بعض العمليات الحسابية")]
public class Class1 : System.Windows.Forms.Form
          public Class1()
          System.Reflection.Assembly as =

          DescriptionAttribute des = (DescriptionAttribute)





Earlier in the first example in Developing Windows Forms Controls section, it showed how you can add a property called Mirrored. Using metadata, you can also add information to describe the Mirrored property:

[Description("هذه الخاصية تقوم بتحديد اتجاه واجهة التطبيق"), _
DefaultValue(False), _
Category("Appearance")> _
Public Property Mirrored() As Boolean
          Return _RTL
        End Get

        Set(ByVal Value As Boolean)
              If Not _RTL.Equals(Value) Then
                _RTL = Value
              End If
        End Set
End Property

Now, when you select the Mirrored property in the property window, the Arabic description will appear as in the following figure:

Web Forms

Web Forms is the ASP.NET technology that allows you to create a user interface for Web-based applications, whether customers are accessing your application from a traditional Web browser or a mobile device. Using Web Forms pages, you can create a browser-neutral UI that does its processing on the Web server, freeing you of the need to create browser-specific (or device-specific) versions of your UI. In Web Forms pages, the user interface programming is divided into two distinct pieces: the visual component and the logic. The visual element is referred to as the Web Forms page. T he page consists of a file containing static HTML, or ASP.NET server controls, or both simultaneously. The logic for the Web Forms page consists of code that you create to interact with the form. The programming logic resides in a separate file from the user interface file. This file is referred to as the "code-behind" file and has an ".aspx.vb" or ".aspx.cs" extension. The logic written in the code-behind file can be written in Visual Basic or Visual C#.

Creating Web Forms Application

In Visual Studio .NET, you can create ASP.NET applications using either Visual Basic .NET or Visual C# .NET. When you are creating a new ASP.NET Web application, you are free to use Arabic in the project name. You can also use Arabic to name the Web pages that you may add to your web project, as shown in the following figure.
Be ware, these Arabic Web page names would not display correctly on operating systems that do not support Arabic, both while viewing and while hosting the page. Therefore it is not recommended to use Arabic names.

Web Forms Designer

The Visual Studio .NET HTML designer provides editors and tools that assist you to create and change HTML documents. The two editing views are:

  • Design view: You can edit HTML pages graphically, insert elements, use drag-and-drop to position and size them, and see the results instantly. For more details, see Design Web Form Interface
  • HTML view: You can edit HTML markup directly, use pop-up lists to insert elements and properties as you edit.

Displaying Right-to-Left Text

When you design Arabic Web Forms pages, the best way to make text flow from right to left is to use the DIR (direction) attribute. It is usually placed in the [HTML] tag or the [BODY] tag, and then controls and HTML elements on the page inherit the specified direction.
The Dir attribute can be used in the following ways:

  • When direction is specified as RTL (right-to-left) in the [HTML] tag, the page will be set with the correct extended styles set so it displays the page as a right-to-left on a bidirectional-enabled system and a vertical scrollbar appears on the left side.
  • When direction is specified as RTL in the [BODY] tag, frames and captions will not inherit the right-to-left direction.
The following HTML code set the Dir attribute to RTL
HTML dir="rtl"
!-- Or --
body dir="rtl" …

You can set the Dir attribute to rtl visually using the Design view using the Properties window, by setting the Dir property of the DOCUMENT object. All the controls on the form would inherit the same settings. However, the Dir attribute can be used individually with other tags like Table and Web Form controls to let them appear as right to left, as in the following example:
TABLE dir="rtl" …
asp:TextBox dir="rtl" …

Designing a Web Forms Interface

In Design view of the HTML Designer, there are two methods to position elements on your HTML document, Flow Layout and Grid Layout. To establish element positioning preferences, set the pageLayout property to FlowLayout or GridLayout. You can set this property through either the Document Property Page or in the Properties window.

Flow Layout
When the pageLayout property is set to FlowLayout, the client Web browser positions elements one after the other, in the order that they occur in your markup. Elements flow from left to right within a line (or from right to left if the Dir attribute of the Web Form set to rtl), and from top to bottom within the page.

Grid Layout
When the pageLayout property is set to GridLayout, elements are displayed at specified locations on the page using absolute positioning. An MS_POSITIONING="GridLayout" attribute is added to the opening tag, and the positioning grid is activated in Design view.

To design an Arabic Web Form, it is recommended that you use flow layout rather than grid layout. A Web Form set to grid layout and with its Dir attribute set to RTL has the following behavior:

  • In Design view, you might design a very wide RTL Web Form which then requires a horizontal scrollbar. If you try to place controls on the left-most part of the Web Form, the page display might not be smooth and in Design view the page might display strangely, as in the following figure:
  • As noted, when you set the Dir property of the Web Form to RTL, the origin of the Web Forms page becomes the top right-hand corner of the page and the vertical scrollbar appears on the left side of the page, as shown in Figure 12. In Design view, if you position controls on the Web Forms page (without using tables and cells) and design your interface to flow from right to left and then display the page in the Web browser, the controls might appear in different positions than they do in Design view. An example is shown in Figure 13. Therefore, the preferred setting is flow layout.

    Figure 12 the position of the Label control in the Design View

    Figure 13 the position of the Label control in the browser

  • In some cases, after designing the interface of the Web Forms page, you might decide to change its direction by setting the Dir attribute of the Web Form to RTL (that is, to localize the page). Changing the direction of the page lets the Web Form change its flow direction to RTL and adjust all the controls' positions relative to the new origin. This adjustment may not be accurate, and as a result, some controls may take different positions, but not the way you expected. For example, imagine a Web Forms page designer with its direction set to LRT. If the page contains a table with many columns that exceed the width of the design area, when you change the direction of the Web Forms page to RTL, the table will be displayed oddly. The following figures illustrate this scenario.

LTR WebForm

After changing the Dir to RTL

HTML and ASP.NET Server Controls

In addition to the simple HTML controls, Visual Studio .NET introduces other types of controls that you can use with the Web Forms pages:

  • HTML server controls: HTML elements exposed to the server so you can program them. HTML server controls expose an object model that maps very closely to the HTML elements that they render.

  • Web server controls: Controls with more built-in features than HTML server controls. Web server controls include not only form-type controls such as buttons and text boxes, but also special-purpose controls such as a calendar.
  • Validation controls: Controls that incorporate logic to allow you to test a user's input. For more details, see the Web Form Validators section.
  • User controls: Controls that you create as Web Forms pages. You can embed Web Forms user controls in other Web Forms pages, which is an easy way to create menus, toolbars, and other reusable elements.
  • All the HTML controls support RTL, in both the design and run time, which you can specify by setting the Dir attribute to rtl. However, the ASP.NET controls support RTL inherently and are considered as Arabic enabled, but with some considerations. The following explain these considerations:
    • When you set the Dir attribute of the Web Form to rtl, while the number settings of the user local is set to context all the server controls display Hindi digits in both design and run time. As an exception, the Dropdownlistand Listbox controls do not display Hindi digits; instead, they always display Latin digits.
    • Sometimes, when you add Arabic text to a Label control and are browsing the page, the text of the control appears clipped from the right edge of the Label, as shown in the following figure:
    • To overcome this problem, you can set the HTML style attribute of the Label control to include right padding as in the following :
      style="PADDING-RIGHT: 5px"
      The result is:

    • The Calendar control supports Arabic calendars, like the Gregorian calendar with Arabic naming, in addition to Hijri dates :

Web Form Validators

The validation controls incorporate logic to allow you to test a user's input. You attach a validation control to an input control to test what the user enters for that input control. Validation controls are provided to allow you to check for a required field, to test against a specific value or pattern of characters, to verify that a value lies within a range, and so on.

The following table lists describes the validation controls and explain how they support Arabic.

Type of validation Control to use Description Arabic support
Required entry RequiredFieldValidator Ensures that the user does not skip an entry. Supports Arabic
Comparison to a value CompareValidator Compares a user's entry against a constant value, or against a property value of another control, using a comparison operator (less than, equal, greater than, and so on). Supports Arabic, but doesn't ignore Diacritics.
Range checking RangeValidator Checks that a user's entry is between specified lower and upper boundaries. You can check ranges within pairs of numbers, alphabetic characters, and dates.

Supports Arabic, but doesn't ignore Diacritics.

Pattern matching RegularExpressionValidator Checks that the entry matches a pattern defined by a regular expression. This type of validation allows you to check for predictable sequences of characters, such as those in social security numbers, e-mail addresses, telephone numbers, postal codes, and so on. Supports Arabic, but doesn't ignore Diacritics.
User-defined CustomValidator Checks the user's entry using validation logic that you write yourself. This type of validation allows you to check for values derived at run time. Supports Arabic.

Web Services

Web Services are components that run on the server and typically include business logic. Like traditional components, they encapsulate specific functionality and can be called from different programs. However, they are available via Web protocols, making them compatible with programs running in different languages, on different computers, and even on different operating systems.
The most important issue in building Arabic-enabled Web services is to send and receive Arabic text correctly, regardless of the configuration of the server or machine that the Web service is running on. Web services support UTF-8 and Unicode, so, they support Arabic language text and send and receive Arabic text correctly.

Globalization and Localization

WIn Visual Studio .NET, there are two parts to creating a world-ready application: globalization, the process of designing applications that can adapt to different cultures, and localization, the process of translating resources for a specific culture. The .NET Framework provides extensive support for developing world-ready applications. The System.Globalization namespace of the .NET Framework contains classes that define culture-related information, including the language, the country and region, the calendars in use, the format patterns for dates, currency, and numbers, and the sort order for strings.

Culture-Specific Classes

When a localized application executes, its appearance is determined by two culture values. (A culture is a set of user preference information related to the user's language, environment, and cultural conventions.) The UI culture setting determines which resources will be loaded. The UI culture is set as CurrentUICulture in Visual Basic .NET or Visual C# .NET code (and UICulturein Web.config files and page directives). The culture setting determines formatting of values such as dates, numbers, currency, and so on. The culture is set as CurrentCulture in Visual Basic or Visual C# code (and Culture in Web.config files and page directives).
The CurrentCulture property's default value is the system's User Locale, which is set in the Regional Options control panel. The CurrentUICulture property's default value is the system's UI Language, which is the language of your system UI. On Windows 2000 and Windows XP MultiLanguage Edition, the CurrentUICulture defaults to the current user UI language settings.
In some instances, you may want to have most of your application change according to the operating system's or user's culture settings, but also have a number or date that does not change. You can have culture-specific classes format the information with the invariant culture, which is associated with the English language but no particular region. Classes that automatically format information according to the culture setting are called culture-specific. S ome culture-specific methods are IFormattable.ToString, Console.Writeline, and String.Format. Some culture-specific functions (in Visual Basic .NET) are MonthName and WeekDayName.

To a specific culture
// C#
// Put the "using" statements at the beginning of the code module
using System.Threading;
using System.Globalization;
// Put the following code before InitializeComponent()
// Sets the culture to Arabic (Saudi Arabia)
Thread.CurrentThread.CurrentCulture = new CultureInfo("ar-SA");
// Sets the UI culture to Arabic (Saudi Arabia)
Thread.CurrentThread.CurrentUICulture = new CultureInfo("ar-SA");

Formatting Date and Time for a Specific Arabic Culture

The DateTime Structure provides methods such as the DateTime. ToString method and DateTime.Parse Method that allow you to perform culture-sensitive operations on a DateTime. Use the DateTimeFormatInfo class to format and display a DateTime based on culture. DateTimeFormatInfo defines how DateTime values are formatted and displayed, depending on the culture. For example, using the ShortDatePattern, the date February 1, 2001 is formatted as 2/1/2001 for the "en-US" culture and 01/02/2001 for the "ar-EG" culture. An instance of DateTimeFormatInfo can be created for a specific culture, or the invariant culture, but not for a neutral culture. See the following example.

using System;
using System.Globalization;
using System.Threading;

public class FormatDate
  public static void Main()
        //suppose the current date is July 9, 2001,
        DateTime dt = DateTime.Now;
        // Set the CurrentCulture property to U.S. English.
        Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
        // Display dt, formatted using the ShortDatePattern
        // and the CurrentThread.CurrentCulture.

        // Create a CultureInfo object for Egyptian in Egypt.
        CultureInfo ci = new CultureInfo("ar-EG");
        // Display dt, formatted using the ShortDatePattern
        // and the CultureInfo object.
        Console.WriteLine(dt.ToString("d", ci));

If you execute this code on July 9, 2001, the output appears as follows:

Using DateTimeFormatInfo, you can get all information about a specific culture like date patterns, time patterns, and AM/PM designators. The following example retrieves the abbreviated day names of the Egyptian culture:

CultureInfo ci = new CultureInfo("ar-Eg");
foreach (string day in ci.DateTimeFormat.AbbreviatedDayNames)

Note:The previous code will return the correct abbreviated day names. It always orders the days of the week starting with Sunday and ending with Saturday.

Working with DateTime Objects
There are some rules that you must be aware of while working with DateTime members:

  1. The methods of the DateTime structure are based on the Gregorian calendar. Even if you change the current calendar in your application's code or change date and time settings through the Regional Options dialog box in Control Panel, the Gregorian calendar is still used to perform the calculations for these methods. Although all the calculations of DateTime depend on Gregorian, the DateTime object retrieves all other information from the current culture. For example, if the current culture set to Arabic, the DateTime will parse and recognize the short date as "dd/MM/yyyy" (like in Arabic) not as "MM/dd/yyyy" (like in English US).
  2. If you want to perform culture-sensitive date and time operations based on the current calendar, you must use the DateTimeFormatInfo.Calendar property to call methods provided by the Calendar class.
  3. Be aware that a DateTime object is a value type and is immutable. Therefore, operations such as DateTime.AddDays return a new DateTime value instead of incrementing an existing value. The following example illustrates how to increment a DateTime by a day using the statement dt = dt.AddDays(1).

Using Calendars with Arabic Cultures

A globalized application should be able to display and use calendars based on a specific culture. The .NET Framework provides the Calendar Class as well as the following Calendar implementations: GregorianCalendar and HijriCalendar and other calendars.
The CultureInfo Class has a CultureInfo.Calendar Property that retrieves a culture's default calendar. Some cultures support more than one calendar. The CultureInfo.OptionalCalendars Property retrieves the optional calendars supported by a culture. For example, the Saudi Arabia culture has 6 calendars, Hijri calendar (as default) plus 5 of different Gregorian calendar types, as specified in the Regional Settings of the Control Panel of the system.

The GregorianCalendar has different language versions of the Gregorian calendar. Using the GregorianCalendar.CalendarType Property you can get or set the GregorianCalendarTypes value that denotes the version of the current GregorianCalendar. The date and time patterns associated with the GregorianCalendar vary depending on the language. For Arabic cultures, more language versions of the Gregorian calendar are available. For example, you can use the French version of GregorianCalendar using the MiddleEastFrench value. For more information see "GregorianCalendarTypes Enumeration" in MSDN

The following example lists the calendar types of the Saudi Arabia culture:

using System.Globalization;
CultureInfo ci = new CultureInfo("ar-SA");
foreach (Calendar cal in ci.OptionalCalendars)
  if(cal is GregorianCalendar)
        GregorianCalendar gc = (GregorianCalendar)cal;

The output is:

Using Hijiri Calendar
You can set a culture to one of its supported calendar types. For example, the Arabic cultures support the Hijri calendar, so, you can set the Arabic culture calendar to Hijiri calendar. As mentioned before, the CultureInfo.Calendar is a read-only property which gets the current calendar, but can't be changed. Instead, you can specify the calendar of the DateTimeFormat.Calendar of the CultureInfo, as in the following code :

// Create a CultureInfo object for Saudi Arabia.
CultureInfo sa = new CultureInfo("ar-SA");
sa.DateTimeFormat.Calendar = new HijriCalendar();

You can perform any operation with Hijri dates in the same way, such as displaying Hijri and converting Hijri from/to Gregorian or other calendars.

The following example converts a date from Gregorian to Hijri and displays it:

DateTime dt;
System.Globalization.DateTimeFormatInfo HijriDTFI;
  dt = Convert.ToDateTime("12/26/2001");
  HijriDTFI = new System.Globalization.CultureInfo("ar-  EG",false).DateTimeFormat;
  HijriDTFI.Calendar = new System.Globalization.HijriCalendar();
  HijriDTFI.ShortDatePattern = "dd/MM/yyyy";
  Console.WriteLine(dt.Date.ToString("f", HijriDTFI)};
catch(Exception ex)

The output is:

The following example converts date from Gregorian to Hijri using two different methods:
DateTime dt = new DateTime(1422, 1,1, new HijriCalendar());

The output is:
      26/11/2001 or 11/26/2001 (according to your current culture settings)

Formatting Numeric Data for a Specific Arabic Culture

The NumberFormatInfo class defines how currency, decimal separators, and other numeric symbols are formatted and displayed based on culture. For example, the currency used in the "en-US" culture is formatted as $123,456,789.00 and 100.000 ج.م. for the "ar-EG" culture.
The following code example displays an integer using the NumberFormatInfo standard currency format ("c") for the specified CurrentCulture setting.

using System;
using System.Globalization;

public class TestClass
    public static void Main()
      int i = 100;
      // Create a CultureInfo object for Arabic in Egypt.
      CultureInfo eg = new CultureInfo("ar-EG");
      // Display the i formatted as currency for the Egyptian
      Console.WriteLine(i.ToString("c", eg));

The output is:
100.000 ج.م.

Note:With Arabic cultures, the currency symbol appears on the left side of the number. To apply this currency format, you can use the Regional Settings of the system, from the Control Panel OR set CultureInfo.NumberFormat.CurrencyNegativePattern and CultureInfo.NumberFormat.CurrencyPositivePattern in the code.

Sorting, Comparing and Searching

Sorting, searching and comparing operations are culture aware, this mean that they are affected by the affected by the system culture. For example, if you are comparing two strings, you have to take into consideration their language. In Arabic, if you are comparing two words, one containing Kashida and other without Kashida, the two words in Arabic are the same, so the comparison result should be equal.

You may need to sort the elements of a collection or list. For example, you might sort a list of employee's names. This sort should be built on the rules of the language of the employee names.
Some data structures, like arrays and controls, such as the Combobox, Listbox, ListView controls consist of elements that can be sorted. Because the .NET Framework based on the Unicode, it sorts the Arabic strings correctly. The following example sorts Arabic strings of a Combobox named Combobox1:

ComboBox1.Sorted = True;


Actually, searching and comparing are the same operation, where the search is a kind of comparing. When you are comparing two words, you can perform either a binary or text compare. The binary compare (or search) compares without considering the local national language or culture, while the text search considers the local national language or culture. For example, if you are comparing two English words "pen" and "Pen," which differ in their case (upper and lower), the result of the binary comparison will be not equal, while the text comparison returns equal. In the Arabic culture, the text comparison should take into consideration the capability of ignoring some special characters, such as Kashida, Diacritics and Alef/Alef-Hamza.
The .NET Framework supports both comparisons through its classes and methods. The CompareInfo class provides a set of methods you can use to perform culture-sensitive string comparisons. The CultureInfo class has a CultureInfo.CompareInfo property that is an instance of this class. This property defines how to compare and sort strings for a specific culture. The String.Compare method uses the information in the CultureInfo.CompareInfo property to compare strings.
For example, consider the String and RichTextBox classes. You can use the String class to make comparison between two strings. The String.CompareOrdinal method makes a binary comparison, as in the following:

String.CompareOrdinal("خالد", "خالــــد") The function will not return 0, which means that the two words are not equal.

The String.Compare method makes a text comparison, where the method takes the culture as a parameter, as in this example:

String.Compare("خالــــد", "خالد", True, New System.Globalization.CultureInfo("ar-EG")) The function will return 0, which means that the two words are equal.

Note String.Compare method doesn't ignore Diacritics or Alef-Hamza, it ignores only Kashida.
The RichTextBox control can be used as a text editor. One of the most useful functions of text editors is to search for a specific string. The Find method of the RichTextBox class searches for text within the contents of the specified RichTextBox control. With this function, you can indicate how a text search is carried out in a RichTextBox control, by specifying the RichTextBoxFinds options as in the following example:

RichTextBox.Find("text…", RichTextBoxFinds.WholeWord | RichTextBoxFinds.MatchCase);

With Arabic:

  • The Find method performs the text comparison only, where it ignores all Kashida, Diacritics and Alef-hamza, even with RichTextBoxFinds.None setting.
  • When the Find method has found the same word but with additional Kashida, the selection or highlight of the matching word will not cover all the word. Instead, it will cover only the same number of characters of the original word that you are searching for. For example, suppose you are searching for "محمد" and the RichTextBox contains "محــمد" with two more additional Kashida, so, the selection will cover only 4 characters like this "محــمد"

Digit substitution system

The .NET Framework follows the same rules as the operating system regarding digit substitution. The digit substitution of the operating system depends on the user locale and how you have set the digit substitution of the regional settings in the control panel.

The .NET Framework gives you the ability to control the digit substitution programmatically. You can use StringFormat.SetDigitSubstitution method, which specifies the method to be used for digit substitution. This function takes two parameters, the language of the text and an element of the StringDigitSubstitute enumeration that specifies how digits are displayed. The following code uses the Arabic-Egypt culture to set the digit substitution to Hindi (Arabic) digits by using StringDigitSubstitute.National element, where the user locale of the system is assumed to be Arabic.

[Visual Basic]
Private Sub Form2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
Handles MyBase.Paint
   Dim drawFormat As New StringFormat()
   Dim eg As New Globalization.CultureInfo("ar-EG")

    drawFormat.SetDigitSubstitution(eg.LCID, StringDigitSubstitute.National)

   Dim drawFont As New Font("Arial", 16)
   Dim drawBrush As New SolidBrush(Color.Black)

   e.Graphics.DrawString("مرحبا بقدوم عام 2002", drawFont, drawBrush, 10, 10, drawFormat)
End Sub

The output is:

Globalizing and Localizing Web Application

Globalization is the process of designing and developing a Web application that functions for multiple cultures and languages, while localization is the process of customizing your Web application for a given culture or locale. (Localization consists primarily of translating the user interface.)The following sections explain how to select the encoding and how to configure the Web application to support globalization.

Encoding support
Internally, the code behind Web Forms pages handles all string data as Unicode. You can set the ResponseEncoding attribute to set the encoding that the server uses to send data to the client, for example UTF-8. The Web Forms page also sets the CharSet attribute on the Content-Type of the HTTP header according to the value of ResponseEncoding.This enables browsers to determine the encoding without a meta tag or having to guess the correct encoding from the content.The RequestEncoding attribute indicates the encoding the server will use to interpret data entered on the client and sent to the server. The FileEncoding attribute specifies the encoding that is used to interpret the data included in the aspx file. If the file encoding is specified in the Web.config file, the actual file must be saved in the same encoding. This may happen if you are developing a Web Form's page which includes Arabic text, for example, while the system locale of your machine is English. In that case, you have to save the Web Form with encoding and select the appropriate Arabic code page. To select an encoding different from the system default, use the Advanced Save Options dialog box (available on the File menu). For details, see Managing Files with Encoding".

To specify encoding and specific culture

  • Set the appropriate encoding in the Web.config file. For more information on Web.config files, see the Web Configuration Settings section.
  • Or
  • Alternatively, in HTML view, add the encoding values to the Page directive:
< Page ResponseEncoding="utf-8" RequestEncoding="utf-8" culture="ar-EG" uiCulture="ar-EG" %>

You can use the Page directive to specify any attribute except for the fileEncoding attribute, because it applies to the file itself. To change the fileEncoding attribute you can set it in the globalization section of the Web.config file.

Web Configuration Settings
Web Forms configuration files are established in an XML file named Web.config. It provides settings for every Web Forms page residing in the same directory as the configuration file. The settings are usually also inherited by subdirectories. Each file can contain a globalization section in which you can specify default encodings and cultures.

The following code set the globalization section in the Web.config file :
< configuration >
< system.web >
  < globalization
< /system.web >
< /configuration >

The attributes of the globalization section in the Web.config file can also be specified in the @ Page directive (with the exception of fileEncoding, which can only be specified in Web.config because it applies to the file itself). Settings in the Page directive are only valid for a specific page and override the settings of the Web.config file.

Localization Support
Properties of a locale are accessible through the CultureInfo class. Additionally, ASP.NET tracks two properties of a default culture per thread and request: CurrentCulture for the default of locale-dependent functions and CurrentUICulture for locale-specific lookup of resource data.
The following code sets the culture to Arabic-Saudi and displays the culture values on the Web server.

<@Import Namespace="System.Globalization" culture="ar-SA" uiCulture="ar-SA"%>

< %=System.Globalization.CultureInfo.CurrentCulture.NativeName % >
< %=System.Globalization.CultureInfo.CurrentUICulture.NativeName% >

The result is as follows:
    (العربية (المملكة العربية السعودية
    (العربية (المملكة العربية السعودية

For locale-dependent data like date/time formats or currency, ASP.NET leverages the support of the .NET Framework class library in the common language runtime. Code on ASP.NET pages can use locale-dependent formatting routines like DateTime.Format. For example, the following code displays the current date in a long format. The first line according to the system locale, the second one according to the Egypt ("EG") locale:

< %=DateTime.Now.ToString("f")%>
< %=DateTime.Now.ToString("f", new System.Globalization.CultureInfo("ar-EG"))%>

The result is as follows:
    Monday, December 03, 2001 10:53 PM
    ‏الثلاثاء, ‏ديسمبر ‏04, ‏2001

Resources in Applications
Nearly every production-quality application needs to use resources. A resource is any non-executable data that is logically deployed with an application. Storing your data in a resource file allows you to change application data without recompiling your entire application. The .NET Framework provides comprehensive support for the creation and localization of resources. In addition, the .NET Framework supports a simple model for packaging and deploying these localized resources.
You can localize your application's resources for specific cultures. This allows you to build localized (translated) versions of your applications. An application loads the appropriate localized resources based on the value of the CultureInfo.CurrentUICulture property. This value is set either explicitly in the application 's code or by the runtime based on the locale for the current user on the local computer.

Crystal Reports

Crystal Reports for Visual Studio .NET is the standard reporting tool for Visual Studio .NET; it brings the ability to create interactive, presentation-quality content, which has been the strength of Crystal Reports for years, to the .NET platform. With Crystal Reports for Visual Studio .NET, you can host reports on Web and Windows platforms and publish Crystal reports as Report Web Services on a Web server. For example, you can create a Web application that enables users to drill down in a chart and filter its information according to their needs. The chart is actually a Crystal report interacting with other controls in the application. When you create a report, you specify the data source of the report, design the report layout, and decide how you want users to access the report data. This section provides an overview of these reporting fundamentals.

Crystal Reports in Applications

CIn Visual Studio .NET, you can create a new Crystal report, or add an existing Crystal report to a project. You can keep the report on a local machine, or publish it as a Web Service on a Web server. Depending on whether you are developing a Windows or Web application, you first bind the report with either the Windows Forms Viewer or the Web Forms Viewer; then you build the application. Users can run the Windows application on a Windows platform, or deploy the Web application on a client browser to view your Crystal report. The Web Forms Viewer and the Windows Forms Viewer each provides a set of properties, methods, and events. You may initialize either viewer's properties at design time or set them at runtime. The following sections focus on the report designing and viewing with respect to Arabic data.

Designing Crystal Reports

Use the Crystal Report Designer to define the report's source of data, to select and group the data records you want to use, and to format the report's objects and layout. The Crystal Report Designer enables you to design and modify reports inside the Visual Studio .NET IDE. The Designer can be directly programmed from within Visual Studio .NET. You do not need to distribute the Report Designer with your report. The Report Designer is divided into labeled report sections. You can place report objects, such as database, formula, parameter, and running total fields, in the section you would like them to appear, as in Figure 14. To access the Crystal Report Designer, you have to add a new report object to your project (.rpt file), and then the Crystal Report Designer launches automatically.

Designing Arabic Report:
To design Arabic report, you have to let the interface flow from right to left. The Crystal Report Designer supports Arabic via the Horizontal Alignment and Reading Order properties. So, there are two main steps to designing an Arabic report:

  1. Design and place the report's controls (Text Objects and Fields) to match the desired right to left layout.
  2. Set the Horizontal Alignment and Reading Order properties, of the Text Objects and Fields controls of the report, to Right and Right to Left, respectively.
  • Right-click on the control and select Format, as in the following figure:
  • For Text Object control, select the Paragraph tab and set the Horizontal Alignment and Reading Order properties, as in the following figure:
  • For Field control, select the Common tab and set the Horizontal Alignment property. Then, select the Paragraph tab to set the Reading Order property, as in the following figure:

Viewing Crystal Reports

There are different ways to view Crystal Reports, depending on whether you are working with a Windows application or a Web application.

Windows Application
If you are developing a Windows application, you can host a report on a Windows Form with the Crystal Reports Windows Forms Viewer, which is available as a control in the Visual Studio Toolbox. As well as providing the convenience of report viewing in a Windows application, the Windows Forms Viewer can interact with other controls in the same application and can dynamically update the report it is hosting. The Windows Forms Viewer contains properties that allow you to customize and control the look, feel, and behavior of your report. For more information see "Reports in Windows Applications" in MSDN. Before you can display a report in the Windows Forms Viewer, you must bind a report object to the viewer. You can do this by assigning the ReportSource property of the Windows Forms Viewer. The Crystal Report Viewer class supports Arabic through its RightToLeft property. By setting the RightToLeft property of the report, or of the Windows Form that hosts the report. The report will run in an Arabic context, but the Report Viewer sill flows from left to right as in the following figure.

Obviously, the CrystalReportViewer control of the Windows Forms has some shortcomings with respect to the right-to-left Windows Forms and Arabic support. These are:

  1. The interface of the CrystalReportViewer control always flows from left to right, even if the Windows Form is set to RTL.
  2. The Text and Field objects don't display Hindi digits even if their Reading Order property is set to RTL.
  3. The Reading Order property of Text Object and Field controls doesn't work properly with Arabic text that includes common characters, as illustrated in the following figure:

Web Forms
If you are developing a Web application in Visual Basic or C#, you can host a Crystal Report on a Web Form with the Crystal Reports Web Forms Viewer, which is available as a control in the Visual Studio Toolbox. In order to display a report in your application, you must add a Web Forms Viewer to your Web Form. The Web Forms Viewer is labeled CrystalReportViewer in the page in Design view. You may initialize properties of the Web Forms Viewer at design time. You can also set or change the Web Forms Viewer's properties in response to user-driven events at run time.
Before you can display a report in the Web Forms Viewer, you must bind the report object to the viewer. You can do this by assigning the DataBindings or the ReportSource property of the Web Forms Viewer.

As other Web controls, to have the CrystalReportViewer control flow from right to left you can set the Dir attribute of the control, HTML or BODY tags to rtl. The CrystalReportViewer control will appear as in the following figure:

As you can see, by setting the Dir attribute with rtl, the Crystal Report Viewer flows from right to left, but it still doesn't match the Arabic interface completely. You can see these problems:

  1. The GroupTree of the CrystalReportViewer control doesn't display properly; it appears on the left side of the report and isn't displayed right to left, as shown in the snapshot.
  2. The zoom factor list of the CrystalReportViewer control continues to display Arabic (Latin) numbers, even if the current culture is set to Arabic.
  3. The page navigation buttons are not displayed properly and the CrystalReportViewer control contains the English word "of" that can't be localized.

©2016 Microsoft Corporation. All rights reserved. Contact Us |Terms of Use |Trademarks |Privacy Statement