DataGrid exception on U+200D in text w/ Arial Unicode MS font

P

Pete Dembrowski

The DataGrid control throws the following exception:

"An unhandled exception of type
'System.Runtime.InteropServices.ExternalException' occurred in
system.windows.forms.dll. Add'l information: "A generic error occurred in
GDI+"

This occurs when I have the 'Font' property set to the "Arial Unicode MS"
font AND send it a string of Unicode-encoded text that contains the Zero
Width Non Joiner character (U+200D). The following code pasted below the
"InitializeComponent" call in a Form ctor will show the problem (of a
default-C# Windows Application project in VS.Net 2003, where the Form has a
DataGrid control named dataGrid1):

+-----------------cut here -----------------+
const string strColumn = "Column name";
DataTable myTable = new DataTable("myTable");
myTable.Columns.Add(new DataColumn(strColumn,typeof(string)));
DataRow rowNew = myTable.NewRow();
myTable.Rows.Add(rowNew);
dataGrid1.DataSource = myTable;

// PROBLEM STATEMENTs begin
rowNew[strColumn] = "\x0938\x091A\x094d\x200d\x091A";
dataGrid1.Font = new Font("Arial Unicode MS", 12);
// PROBLEM STATEMENTs end
+-----------------cut here -----------------+

If you either a) remove the "\x200d" portion of the string or b) comment out
the change of Font property (i.e. so it remains the default "Microsoft Sans
Serif" font), then it works fine.

Any ideas on a fix (besides using a different font?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top