• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 518
  • Last Modified:

No resize of the column width of the Data grid

I set the width of the columns of the datagrid.
I don't want during runtime user should change
it. How should I prevent from doing this


Thanks
0
jra2002
Asked:
jra2002
  • 5
  • 2
1 Solution
 
iboutchkineCommented:
Public Class MyDataGrid
 
      Inherits DataGrid
 
     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
 
          Dim hti As DataGrid.HitTestInfo = Me.HitTest(New Point(e.X,e.Y))
 
          If hti.Type = DataGrid.HitTestType.ColumnResize Then
 
               Return 'no baseclass call
 
          End If
 
          MyBase.OnMouseMove(e)
 
     End Sub
 
End Class
 

0
 
jra2002Author Commented:
In the Windows form
the name of the form is frmDisplayInformation

In that I have the datagrid name dgIccp

Public Class frmDisplayInformation
    Inherits System.Windows.Forms.Form

..
....
.....
Public Class dgIccp
 
      Inherits DataGrid
 
     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
 
          Dim hti As DataGrid.HitTestInfo = Me.HitTest(New Point(e.X,e.Y))
 
          If hti.Type = DataGrid.HitTestType.ColumnResize Then
 
               Return 'no baseclass call
 
          End If
 
          MyBase.OnMouseMove(e)
 
     End Sub
 
End Class


End Class

Could u please let me know what I need to do
0
 
jra2002Author Commented:
Dear iboutchkine
I am doing as above as u mentioned but still not working
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
iboutchkineCommented:
add this procedure to your class


    Protected Overrides Sub onMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
        Dim hti As DataGrid.HitTestInfo = dgIccp.HitTest(New Point(e.X, e.Y))
        If hti.Type = DataGrid.HitTestType.ColumnResize Then
            Return 'no baseclass call
        End If
        MyBase.OnMouseMove(e)
    End Sub
0
 
Moizsaif123Commented:
if you are using a datagrid control from a WebForm app. in .NET then i dont think a user can resize the coloumns width or height...to set the colomns width and height attributes


<asp:BoundColumn DataField="Drug" HeaderText="Medication">
            <ItemStyle HorizontalAlign="Center" Width="444px"  VerticalAlign="Middle"></ItemStyle>
</asp:BoundColumn>
0
 
jra2002Author Commented:
Which class form class?
0
 
jra2002Author Commented:
I had added to the form class still I am able to resize column width of the grid
0
 
jra2002Author Commented:
Dear Moizsaif123
I am using Windows Form
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now