12,829,660 members (44,724 online)
Rate this:
See more:
Hello,

I Wanted to Convert Devanagari Numbers to Numbers and vice-verse,
I'm using following

```        public static string ToNumberString(string num)
{
string[] devNumbers = { "१", "२", "३", "४", "५", "६", "७", "८", "९", "०" };
string[] numbers = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
string strReplaced = num;

int i;
for (i = 0; i < devNumbers.Length; i++)
{
strReplaced = strReplaced.Replace(devNumbers[i], numbers[i]);
}
return strReplaced;
}

public static string ToDevnagariNumberString(string num)
{
string[] devNumbers = { "१", "२", "३", "४", "५", "६", "७", "८", "९", "०" };
string[] numbers = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
string strReplaced = num;

int i;
for (i = 0; i < devNumbers.Length; i++)
{
strReplaced = strReplaced.Replace(numbers[i], devNumbers[i]);
}
return strReplaced;
}
```

Well, the code above works fine,

Is there a way to use above code to display and use Devanagari Numbers in `DateTimePicker `or any workaround for same,
also I'm using Numbers converted to Devanagari Numbers in `DataGridView`, how to convert them to Numbers and SORT and convert back to Devanagari Numbers
Posted 13-Feb-13 5:37am
CHill60 13-Feb-13 10:59am

Can't answer your first point, but on the sorting could you load the equivalent converted numbers to a non-visible column in the DataGridView and sort on that column rather than the Devanagari displayed column

Rate this:

## Solution 1

Hi
Here is an elegant way of doing it.

```private Dictionary<int, string> m_devanagari;

public void InitialiseDevanagari()
{
m_devanagari = new Dictionary<int, string>();

int count = 1;
}

public int GetNumberFromDevanagari(string devanagariNumber)
{
var result = m_devanagari.FirstOrDefault(item => item.Value.Equals(devanagariNumber));
return result.Key;
}

public string GetDevanagariFromNumber(int number)
{
var result = m_devanagari.FirstOrDefault(item => item.Key.Equals(number));
return result.Value;
}

private void populateDataGrid()
{
var devanagariArray = from row in m_devanagari select new { Number = row.Key, Devanagari = row.Value };
dataGridView1.DataSource = devanagariArray.ToArray();
}```

To use this on the DateTime picker, you may have to owner draw the individual date boxes, have look at this link below.

Windows Hijri Calendar[^]

I hope this helps.

Regards
Jegan
Firdaus Shaikh 13-Feb-13 13:22pm

Hello Jegan,
Thanks for above code, Let me try and If this works I'll accept it as answer,
By the way

` int count = 0; m_devanagari.Add(count++, "०"); //This will take value zero m_devanagari.Add(count++, "१"); m_devanagari.Add(count++, "२"); m_devanagari.Add(count++, "३"); m_devanagari.Add(count++, "४"); m_devanagari.Add(count++, "५"); m_devanagari.Add(count++, "६"); m_devanagari.Add(count++, "७"); m_devanagari.Add(count++, "८"); m_devanagari.Add(count++, "९");`

Thanks,
Firdaus Shaikh
Firdaus Shaikh 13-Feb-13 14:13pm

System.Globalization contains 16 Calendars including `HijriCalendar`
but not devanagari
Rate this:

## Solution 2

Hi

Yes That's correct, I missed that "0" bit out. Regarding the calendar, then you may have to owner draw. See this article

Another Month Calendar[^]

Regards
Jegan
Firdaus Shaikh 12-Mar-13 3:24am

Hello Jegan Thiyagesan,
Sorry for late reply,

I'll give it a try and if solves my problem, I'll accept your suggestion as solution,
Thanks by the way,
Firdaus Shaikh

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

Top Experts
Last 24hrsThis month
 ppolymorphe 185 Jochen Arndt 141 OriginalGriff 135 F-ES Sitecore 105 CHill60 45
 OriginalGriff 5,757 Graeme_Grant 3,960 Karthik Bangalore 3,716 ppolymorphe 2,984 Jochen Arndt 2,880

Advertise | Privacy | Mobile
Web01 | 2.8.170326.1 | Last Updated 14 Feb 2013