نوشته شده توسط
پرستو پارسایی
ممنونم از پاسخ شما . من در این دیتا گرید در یک ستون از فرمت ساعت استفاده کردم و الان با توجه به اینکه دیتا گریدم ReadOnly هست و نیاز به Edit نداره قصد دارم بجای نمایش فارسی در درون سلول مورد نظر از نمایش بصورت لاتین استفاده بشه ممنون میشم به این مورد اشاره بفرمایید سپاسگزارم
این مثال کوچک رو اجرا کنید :
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DataGridView1.Columns.Clear()
DataGridView1.Columns.Add("ColumnTime", "Time")
DataGridView1.Columns.Add("ColumnMode", "Mode")
DataGridView1.Rows.Add("12:34", "Farsi")
DataGridView1.Rows.Add("12:34", "Latin")
DataGridView1.Rows.Add("12:34", "Arabic")
End Sub
Private Sub DataGridView1_CellPainting(sender As Object, e As DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
If e.RowIndex >= 0 AndAlso e.ColumnIndex = 0 Then
e.Handled = True
e.Paint(e.ClipBounds, e.PaintParts And (DataGridViewPaintParts.All Xor DataGridViewPaintParts.ContentForeground))
Dim format = New StringFormat(StringFormat.GenericDefault)
Select Case e.RowIndex
Case 0
format.SetDigitSubstitution(1065, StringDigitSubstitute.National)
Case 1
format.SetDigitSubstitution(1033, StringDigitSubstitute.National)
Case 2
format.SetDigitSubstitution(1025, StringDigitSubstitute.National)
End Select
Dim selected = (e.State And DataGridViewElementStates.Selected) = DataGridViewElementStates.Selected
Using brush = New SolidBrush(IIf(selected, e.CellStyle.SelectionForeColor, e.CellStyle.ForeColor))
e.Graphics.DrawString(e.FormattedValue, e.CellStyle.Font, brush, e.CellBounds, format)
End Using
End If
End Sub
End Class