Allowing only rowselection in a datagrid

Mario Michiels

New member
Joined
Apr 14, 2005
Messages
2
Programming Experience
Beginner
I would like a datagrid where you can only select by row. I can allready automatically select the rows :

Private Sub myDataGrid_CurrentCellChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles myDataGrid.CurrentCellChanged
myDataGrid.Select(myDataGrid.CurrentRowIndex)
End Sub

but the datagrid also still selects the text of the current cell in that row so you
can still select and copy the text of that cell.

How can I prevent the users from entering the cells in my grid leaving them only able to browse and select by row ?

Also when you use the scrollbutten on the mouse you scroll only a couple of rows and then it stops.

How do I enbable scrolling through the whole grid ?

Thanks in advance !
 

mzim

Well-known member
Joined
Jun 3, 2004
Messages
187
Location
Other side of the rock
Programming Experience
1-3
Mario Michiels said:
I would like a datagrid where you can only select by row. I can allready automatically select the rows :

Private Sub myDataGrid_CurrentCellChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles myDataGrid.CurrentCellChanged
myDataGrid.Select(myDataGrid.CurrentRowIndex)
End Sub

but the datagrid also still selects the text of the current cell in that row so you
can still select and copy the text of that cell.

How can I prevent the users from entering the cells in my grid leaving them only able to browse and select by row ?

Also when you use the scrollbutten on the mouse you scroll only a couple of rows and then it stops.

How do I enbable scrolling through the whole grid ?

Thanks in advance !

to prevent users editing a cell, set your datagrid readonly property to true.
 

Mario Michiels

New member
Joined
Apr 14, 2005
Messages
2
Programming Experience
Beginner
Well, I allready set the readonly to true. And no, now I can't change the contents of the cells BUT you can still copy the text in the cells.

I want something like a listbox where you can only go up and down the rows and that's it. The endgoal is that the user can doubleclick on any row in the datagrid and then an new dataform opens where the user can change the data of the selected record.

Is this even possible in a datagrid ? Or are there any other solutions (besides purchasing Janusgrid or something) ?

Thanks again !
 

mzim

Well-known member
Joined
Jun 3, 2004
Messages
187
Location
Other side of the rock
Programming Experience
1-3
Mario Michiels said:
Well, I allready set the readonly to true. And no, now I can't change the contents of the cells BUT you can still copy the text in the cells.

I want something like a listbox where you can only go up and down the rows and that's it. The endgoal is that the user can doubleclick on any row in the datagrid and then an new dataform opens where the user can change the data of the selected record.

Is this even possible in a datagrid ? Or are there any other solutions (besides purchasing Janusgrid or something) ?

Thanks again !

yeah it is really possible in datagrid.
try this one.
VB.NET:
Private Sub DataGrid1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.DoubleClick
		Dim f As New Form3()
		f.TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 0).ToString
'it fetches the first column data 
		f.ShowDialog()
	End Sub
 
Top Bottom