Can some one help me please
In my program i need to turn off the enable of the datagrid
the problem that when I turn it on again it's scrollbar becomes inactive , so the user can't use it to move between the datagrid rows
I use VB 2003
thanks for your help

Datagrid Scrollbar
FlashFan
Use the readonly property which would set the grid so you could enter or chnage anything but the scrollbars would still be active enabling you to scroll around and view the data.
DominicPukallus
are you sure that scrollbars property of the DataGrid is not none
Luke Westendorf MSFT
Thanks for your reply,
but the problem is that I need to close the Datagrid so the user can'nt choose another row for some minutes to make changes in other data in textboxs
the readonly property stop editing but the user can still move between the rows
if the user change the row , it will change the data in textboxs
WV John
You can still use the readonly - but you have to code around it a little. In my example I have a button which I can disable further changes to be made and whilst it disallows changes to be made the selected value remains but it allows me to scroll around the grid and the values are readonly - when I reclick the button to reenable selection of rows then editing is re-enabled.
You just have to maintain the selected item you want to preserve and handle this.
Example
Public Class Form1
Dim blnNoChnage As Boolean = False
Dim selrow As Integer '//Currently Selected Row
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'//Populate the datagridview
Dim dt As New DataTable
dt.Columns.Add("1")
dt.Columns.Add("2")
dt.Rows.Add(1, 2)
dt.Rows.Add(2, 2)
dt.Rows.Add(3, 2)
dt.Rows.Add(4, 2)
Me.DataGridView1.DataSource = dt
Me.DataGridView1.MultiSelect = False
Me.DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
blnNoChnage = Not blnNoChnage '//Toggles between allow or not allowing selected row to be changed
Me.DataGridView1.ReadOnly = blnNoChnage
End Sub
Private Sub DataGridView1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
If Me.DataGridView1.SelectedRows.Count > 0 Then
'// If no chnage allowed then reset the selected row back to what it should be
'// else allow the chnage to take place and update the selrow variable
If blnNoChnage = True Then
CType(sender, DataGridView).Rows(selrow).Selected = True
Else
selrow = CType(sender, DataGridView).CurrentRow.Index
End If
Label1.Text = Me.DataGridView1.SelectedRows(0).Cells(0).Value
End If
End Sub
End Class