Solved

No resize of the column width of the Data grid

Posted on 2004-04-01
8
508 Views
Last Modified: 2008-03-17
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
Comment
Question by:jra2002
  • 5
  • 2
8 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 50 total points
Comment Utility
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
 

Author Comment

by:jra2002
Comment Utility
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
 

Author Comment

by:jra2002
Comment Utility
Dear iboutchkine
I am doing as above as u mentioned but still not working
0
 
LVL 28

Expert Comment

by:iboutchkine
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 4

Expert Comment

by:Moizsaif123
Comment Utility
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
 

Author Comment

by:jra2002
Comment Utility
Which class form class?
0
 

Author Comment

by:jra2002
Comment Utility
I had added to the form class still I am able to resize column width of the grid
0
 

Author Comment

by:jra2002
Comment Utility
Dear Moizsaif123
I am using Windows Form
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now