السـلام عليكم روحمة الله وبركاته
عندي داتا قريد فيـو تعرض البيانات محتاج أضيف لداتا قريدفيـو علامة تشك في كل صف بحيث أنه إذا عمل علامة تشك تصير خاصية الصف الأنيبل = مفعله
طبعاً موجود عمود في قاعدة البيانات بترو أو فولس
شـــاكر ومقدر
معقوله 30 رد ولا فيه مشـاركه وحده ..؟
ممكن أحد يعدل لي المثال على سكيـول سيرفر
تفضل اخي الكريم المثال بعد التعديل الى SQL Server
الله يسعدك ياغالي وأشكرك على مرورك الرائع
(16-02-16, 01:48 AM)khodor1985 كتب : [ -> ]السلام عليكم أخي العزيز ورحمة الله وبركاته
لقد تم تنفيذ المثال بناء لطلبك
الأكواد :
أستدعاء مكتبة OLEDB:
PHP كود :
Imports System.Data.OleDb
الإغلان عن المتغيرات التالية :
PHP كود :
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\MyDB.accdb")
Dim cmd As OleDbCommand
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim RecordCount As Integer
تحميل البيانات من قاعدة البيانات إلى DataGrid :
PHP كود :
Try
con.Open()
Dim StrSelect As String = "SELECT * From Person"
cmd = New OleDbCommand(StrSelect, con)
da = New OleDbDataAdapter(cmd)
ds = New DataSet
ds.Clear()
RecordCount = da.Fill(ds)
If RecordCount > 0 Then
DGVData.DataSource = ds.Tables(0)
da.UpdateCommand = New OleDbCommandBuilder(da).GetUpdateCommand
End If
If con.State = ConnectionState.Open Then con.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
ActiveCell()
إنشاء إجراء مستقل للتحكم بفعالية الصف في DataGrid :
PHP كود :
Sub ActiveCell()
For i = 0 To DGVData.Rows.Count - 1
With DGVData.Rows(i)
Dim MyCheck As Boolean = .Cells(4).Value
If MyCheck = True Then
.Cells(0).ReadOnly = True
.Cells(1).ReadOnly = True
.Cells(2).ReadOnly = True
.Cells(3).ReadOnly = True
.DefaultCellStyle.BackColor = Color.LightGray
Else
.Cells(0).ReadOnly = False
.Cells(1).ReadOnly = False
.Cells(2).ReadOnly = False
.Cells(3).ReadOnly = False
.DefaultCellStyle.BackColor = Nothing
End If
End With
Next
End Sub
أاستدعاء الإجراء المستقل إلى الحدث CellValueChanged في DataGrid :
النتيجة :
المرفق :
أتمنى لك التوفيق
جزاك الله خيرا
يـاجماعة الخيـر عندي هالمشكله اللي أستمرت معاي بدون حل هذا الكود
[
attachment=9598]
كود :
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