Click here to Skip to main content
Licence CPOL
First Posted 20 Sep 2008
Views 16,816
Bookmarked 17 times

How to Make an Arabic Column in DataGridView

By | 20 Sep 2008 | Article
Arabic Column in DataGridView

Introduction

Some people make applications that have an Arabic Interface. We cannot name any column in Arabic in any RDBMS, however DataGridView can solve this problem by giving an Arabic name to your column when you display your data.

Using the Code

There are two ways to make an Arabic column in DataGridView.

The first way is very easy and can be done by changing the header text of DataGridView as follows:

dataGridView1.Columns[0].HeaderText = "???????";

dataGridView1.Columns[1].HeaderText = "?????";

dataGridView1.Columns[2].HeaderText = "?????";

The second way is that DataGridViewTextBoxColumn is used to host cells that enable displaying and editing of text strings.

Steps

  1. Create an instance from DataGridViewTextBoxColumn class

  2. Add cells you created to be hosted in dataGridView1:

    dataGridView1.Columns.AddRange(new DataGridViewTextBoxColumn[] {
            idDataGridViewTextBoxColumn,
            nameDataGridViewTextBoxColumn,
            ageDataGridViewTextBoxColumn});
  3. Ok, after you add cells to dataGridView, you want to make a link between the cell which you write Arabic text on and the column:

    idDataGridViewTextBoxColumn.DataPropertyName = "id";
    idDataGridViewTextBoxColumn.HeaderText = "?";

Example

DataGridViewTextBoxColumn idDataGridViewTextBoxColumn;
DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn;
DataGridViewTextBoxColumn ageDataGridViewTextBoxColumn;

private void Form1_Load(object sender, EventArgs e)
{
    idDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
    nameDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
    ageDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();

    dataGridView1.Columns.AddRange(new DataGridViewTextBoxColumn[] {
        idDataGridViewTextBoxColumn,
            nameDataGridViewTextBoxColumn,
            ageDataGridViewTextBoxColumn});

        using (SqlConnection sqlCon = new SqlConnection(
            @"Data Source=.\SQLEXPRESS;AttachDbFilename=" +
            "C:\Documents and Settings\Administrator\My Documents\AhmedRabie.mdf;" +
            "Integrated Security=True;Connect Timeout=30;User Instance=True"))
        {
            SqlCommand cmd = sqlCon.CreateCommand();
            cmd.CommandText = "Select * from StudentInfo";
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = cmd;
            DataSet dset = new DataSet();
            adapter.Fill(dset);

            idDataGridViewTextBoxColumn.DataPropertyName = "id";
            idDataGridViewTextBoxColumn.HeaderText = "?";
            idDataGridViewTextBoxColumn.Name = "idDataGridViewTextBoxColumn";
            // 
            // nameDataGridViewTextBoxColumn
            // 
            nameDataGridViewTextBoxColumn.DataPropertyName = "name";
            nameDataGridViewTextBoxColumn.HeaderText = "?????";
            nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
            // 
            // ageDataGridViewTextBoxColumn
            // 
            ageDataGridViewTextBoxColumn.DataPropertyName = "age";
            ageDataGridViewTextBoxColumn.HeaderText = "?????";
            ageDataGridViewTextBoxColumn.Name = "ageDataGridViewTextBoxColumn";

            dataGridView1.DataSource = dset.Tables[0];
        }
}

History

  • 20th September, 2008: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Ahmed R El Bohoty

Web Developer
ITeShare
Egypt Egypt

Member

I am interested in Software architecture, Requirements Engineering and coding. I am MCP ,SCJP,MCTs,MCPD, Brainbench.
 
http://ahmedbohoty.blogspot.com/

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralDatagridview PinmemberSaad_ang4:43 4 May '11  
GeneralMy vote of 1 PinmemberMohm'ed Melhem2:20 3 Aug '09  
Questionand how can we do following Pinmembersairfan121:56 21 Nov '08  
Generalالف شكر يا حمد Pinmemberegyptionyouth18:45 3 Oct '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 20 Sep 2008
Article Copyright 2008 by Ahmed R El Bohoty
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid