28-02-16, 11:01 AM
يـاجماعة الخيـر عندي هالمشكله اللي أستمرت معاي بدون حل هذا الكود
كود :
DAT;Integrated Security=True
Dim cmd33 As SqlCommand
Dim das As SqlDataAdapter
Dim dss As DataSet
Dim RecordCount As Integer
Private Sub DATAG_CellValueChanged(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DATAG.CellValueChanged
ActiveCell()
End Sub
Sub ActiveCell()
For i = 0 To DATAG.Rows.Count - 1
With DATAG.Rows(i)
Dim MyCheck As String = .Cells(6).Value.ToString
If MyCheck = "True" Then
.Cells(0).ReadOnly = True
.Cells(1).ReadOnly = True
.Cells(2).ReadOnly = True
.Cells(3).ReadOnly = True
.Cells(4).ReadOnly = True
.Cells(5).ReadOnly = True
.Cells(6).ReadOnly = True
.DefaultCellStyle.BackColor = Color.LightGray
Else
.Cells(0).ReadOnly = False
.Cells(1).ReadOnly = False
.Cells(2).ReadOnly = False
.Cells(3).ReadOnly = False
.Cells(4).ReadOnly = False
.Cells(5).ReadOnly = False
.Cells(6).ReadOnly = False
.DefaultCellStyle.BackColor = Nothing
End If
End With
Next
End Sub
Sub hht()
Try
conne.Open()
Dim StrSelect As String = "SELECT * From hala"
cmd33 = New SqlCommand(StrSelect, conne)
'Update()
das = New SqlDataAdapter(cmd33)
dss = New DataSet
ds.Clear()
RecordCount = das.Fill(dss)
If RecordCount > 0 Then
DATAG.DataSource = dss.Tables(0)
das.UpdateCommand = New SqlCommandBuilder(das).GetUpdateCommand
End If
If conne.State = ConnectionState.Open Then conne.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
ActiveCell()
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
da = New SqlDataAdapter("SELECT * FROM hala ", conn)
da.Fill(dt)
DATAG.DataSource = dt
With DATAG()
.RowsDefaultCellStyle.SelectionBackColor = Color.PaleGoldenrod
.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
.RowsDefaultCellStyle.SelectionForeColor = Color.Black
.ColumnHeadersDefaultCellStyle.BackColor = Color.Gainsboro
.Columns(0).HeaderText = "الرقم التسلسلي"
.Columns(1).HeaderText = "أسم "
.Columns(2).HeaderText = "رقم الخطاب"
.Columns(3).HeaderText = "جهة البرقيه "
.Columns(4).HeaderText = "الأجـــراء"
.Columns(5).HeaderText = "تـاريخ الأرسـال"
.Columns(6).HeaderText = "تحقق"
' -------------------------------
.Columns(0).Width = 180
.Columns(1).Width = 350
.Columns(2).Width = 195
.Columns(3).Width = 200
.Columns(4).Width = 150
.Columns(5).Width = 230
.Columns(6).Width = 120
.DefaultCellStyle.Font = New Font("Times New Roman", 14, FontStyle.Bold)
.ColumnHeadersDefaultCellStyle.Font = New Font("Times New Roman", 16, FontStyle.Bold)
.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize
hht()
.Refresh()
End With
End Sub
