JarHead Posted January 28, 2005 Posted January 28, 2005 I need help to configure the Datagrid control to: Select the entire row when clicked (not just a cell). Set individual column widths. Make data displayed read only. I've been searching google for a few hours, and couldn't find anything, please help if you can. Quote
penfold69 Posted January 28, 2005 Posted January 28, 2005 1. Select entire row when clicked: Private Sub grdData_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdData.MouseUp Dim hti As DataGrid.HitTestInfo = grdData.HitTest(e.X, e.Y) If hti.Type = DataGrid.HitTestType.Cell Then grdData.Select(hti.Row) End If End Sub Set individual column widths: Dim ts As New DataGridTableStyle Dim col1 As New DataGridTextBoxColumn col1.MappingName = "ID" col1.HeaderText = "ID" col1.Width = 0 col1.NullText = "" ts.GridColumnStyles.Add(col1) Dim col2 As New DataGridTextBoxColumn col2.MappingName = "ACTUAL_TIME" col2.HeaderText = "Time" col2.Width = 40 col2.NullText = "" ts.GridColumnStyles.Add(col2) ' Repeat for each column grdData.TablesStyles.Clear() grdData.TablesStyles.Add(ts) Make data displayed read only: grdData.ReadOnly = True Quote
Kid_Icarus Posted May 24, 2005 Posted May 24, 2005 1. Select entire row when clicked: Private Sub grdData_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdData.MouseUp Dim hti As DataGrid.HitTestInfo = grdData.HitTest(e.X, e.Y) If hti.Type = DataGrid.HitTestType.Cell Then grdData.Select(hti.Row) End If End Sub Thank you very much for this code! I have been looking for this... (just found this thread) The Kid. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.