منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : تلوين نص في جدول البيانات
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
سلامي للجميع 

عندي جدول البيانات DataGridView الموضح في الصوره المرتبط بقاعده بيانات اكسس اريد التمييز باللاوان للتقديرات حاولت وعملت على الاكود الموضحه في الصوره ومافي نتيجه فاين الاشكاليه
في غلط في الكتابه
استخدم حدث CellFormatting للداتا جرد فيو
مثال 
كود :
For Each MiColumna As DataGridViewRow In DataGridView 1.Rows

            If MiColumna.Cells(5).Value.ToString() = "FaceBook" Then
               MiColumna.DefaultCellStyle.BackColor = Color.White
               MiColumna.DefaultCellStyle.ForeColor = Color.Black
           ElseIf MiColumna.Cells(5).Value.ToString() = "" Then
               MiColumna.DefaultCellStyle.BackColor = Color.LightGreen
               MiColumna.DefaultCellStyle.ForeColor = Color.Black
           ElseIf MiColumna.Cells(5).Value.ToString() = "" Then
               MiColumna.DefaultCellStyle.BackColor = Color.LightGreen
               MiColumna.DefaultCellStyle.ForeColor = Color.Black
            ElseIf MiColumna.Cells(5).Value.ToString() = "" Then
               MiColumna.DefaultCellStyle.BackColor = Color.LightGreen
               MiColumna.DefaultCellStyle.ForeColor = Color.Black
            ElseIf MiColumna.Cells(5).Value.ToString() = "" Then
               MiColumna.DefaultCellStyle.BackColor = Color.LightGreen
               MiColumna.DefaultCellStyle.ForeColor = Color.Black
           Else
               MiColumna.DefaultCellStyle.BackColor = Color.White
               MiColumna.DefaultCellStyle.ForeColor = Color.Black
           End If
       Next
عدل على المثال كما تريد وضعه في الحدث الذي تكلمت عته
الحمد لله جربت كود اخر والنتيجه تمام والشكر للاخ العزيز / aljzazy  الذي فتح لي طريق عن طريق الحدث CellFormatting


الكود للافاده
PHP كود :
Private Sub DataGridView1_CellFormatting(ByVal sender As ObjectByVal e As DataGridViewCellFormattingEventArgsHandles DataGridView1.CellFormatting
        
' تحديد العمود الذي ترغب في تلوين قيمه
        Dim targetColumnIndex As Integer = 5 ' 
تغيير القيمة حسب رقم العمود الخاص بك

        If e
.ColumnIndex targetColumnIndex AndAlso e.Value IsNot Nothing Then
            Dim cellValue 
As String e.Value.ToString()

 
           ' التحقق من القيمة وتعيين الألوان المناسبة
            If cellValue = "Facebook" Then
                e.CellStyle.BackColor = Color.Yellow
                e.CellStyle.ForeColor = Color.Black

            ElseIf cellValue = "Excellent" Then
                e.CellStyle.BackColor = Color.LightGreen
                e.CellStyle.ForeColor = Color.Black

            ElseIf cellValue = "Excellent" Then
                e.CellStyle.BackColor = Color.LightGreen
                e.CellStyle.ForeColor = Color.Black

            ElseIf cellValue = "Excellent" Then
                e.CellStyle.BackColor = Color.LightGreen
                e.CellStyle.ForeColor = Color.Black

            ElseIf cellValue = "Excellent" Then
                e.CellStyle.BackColor = Color.LightGreen
                e.CellStyle.ForeColor = Color.Black

            End If
            ' 
يمكنك إضافة المزيد من الشروط حسب احتياجاتك

            
' قم بتعيين القيمة المعدلة إلى الخلية
            e.Value = cellValue
        End If
    End Sub
End Class