I have a database which contains Hebrew language(foreign characters) in it.

When I populate it in grid view. It gets populated in reverse order(left to right)

For example: "כן" is getting populated as "ןכ"

You have to reverse the words, you can use a method to do it so:

public string Reverse(string str)
        {
            int len = str.Length;
            char[] arr = new char[len];

            for (int i = 0; i < len; i++)
            {
                arr[i] = str[len - 1 - i];
            }

            return new string(arr);
        }

how could i reverse data in gridview,
i'm using fill() method to populate the grid view

You will have to populate it manually to reverse data in every cell Im affraid.
Manual popultion means that you will have to loop through all the gridView (by rows, and then by cells, and get the appropriate data for a specific cell, according to the cell`s indexes (column and row).

thanks mitja, let me try this and see

no mitja,
This didn't solve my problem, because my data even contain English characters and numbers,


Can you help me in this?

if you parsed the whole grid cell by cell, you could also parse the text in each cell and check each character's ascii code. if it's between 65-90 and 97-122 these are latin alphabet.

if you parsed the whole grid cell by cell, you could also parse the text in each cell and check each character's ascii code. if it's between 65-90 and 97-122 these are latin alphabet.

sorry pitic i couldn't understand?

can you be little bit clearer?

How to change the each character's ASCII code,;

How can we set Encoding for Grid view control

try this to verify ascii code for each character in cell

//DataGridView dgv1 = new DataGridView();
for (int i = 0; i < dgv1.Columns.Count; i++)
            {
                for (int j = 0; j < dgv1.Rows.Count; j++)
                {
                    string cellValue = dgv1[i, j].Value.ToString();
                    foreach (char c in cellValue)
                    {
                        if (Convert.ToInt32(c) < 127)
                        {
                            //this is ascii
                        }
                        else
                        {
                            //this is not ascii
                        }
                    }
                }

of course this assumes your cells contain valid data (string, int...)

Hi Pictic,Thanks for your help
When i read the characters from the grid view I'm getting it is not ASCII value.

else
{//this is not ASCII}

but when it gets displayed in the grid view I'm getting reversed.

the code was to test the characters if they are latin ascii or not. in the else clause you have to specify what to do with the non latin characters. please export your table data (or some of it if it's valuable data) in a csv file or text file (preferably column based) so i can test the else clause

"12.04.2011","אברמוב בני","052-8374806","₪ 10,500","לא","220 מ\"ר","7","קרקע מתוך 0","ראשון לציון","אין","כן","","","כן","כן","אין","כן","נאות שיקמה","וילות );

This is a sample data,
I think problem is in gridview, We have set Encoding or Charset for grid view so that it displays the content in the correct format

Hey, sorry for not posting in a while... busy weeks at work.

So, I tried to populate the grid with text you specified, but as far as i can see it writes the text correctly. (meaning it's printed just like in the text file). i uploaded a screenshot for you to check if this is ok.

it's ok pictic

Hey, sorry for not posting in a while... busy weeks at work.

So, I tried to populate the grid with text you specified, but as far as i can see it writes the text correctly. (meaning it's printed just like in the text file). i uploaded a screenshot for you to check if this is ok.

Can you please upload with the sample data which i gave, did you uploaded datagridview from access database using C#

Thank you for putting effort for me, take a look at this thread too please

i have used the sample data you provided but not from access it was populated in the code.

(i actually don't have access installed)

But i am not getting it.. did you populated in grid view??

i used this to populate

dataGridView1.Rows.Add("1000");
dataGridView1.Rows.Add("1653");
dataGridView1.Rows.Add("dweqf");
dataGridView1.Rows.Add("שיקמה");
dataGridView1.Rows.Add("שיקמה");
dataGridView1.Rows.Add("₪ 10,500");
dataGridView1.Rows.Add("קרקע מתוך 0");
dataGridView1.Rows.Add("שיקמה");
dataGridView1.Rows.Add("שיקמה");

and i've configured dataGridView1.RightToLeft = RightToLeft.No setting that property to yes does indeed right from right to left but only on some characters. like ("₪ 10,500") is printed as "₪ 10,500". as far as i can see, not all the characters are right to left writing.

when moving cursor through the characters to delete them on some chars "backspace" works as intended (deleting from right to left) but on some it deletes the other way (from left to right). this is the same case with "delete" key.

and it happens inside the the same hebrew char string.

No pitic, I am sorry, I am not getting populated in correct order, Even i did what you have done. It's not working..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.