Solved

No resize of the column width of the Data grid

Posted on 2004-04-01
8
514 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 50 total points
ID: 10732326
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
ID: 10732401
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
ID: 10732433
Dear iboutchkine
I am doing as above as u mentioned but still not working
0
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
LVL 28

Expert Comment

by:iboutchkine
ID: 10732492
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
 
LVL 4

Expert Comment

by:Moizsaif123
ID: 10732507
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
ID: 10732516
Which class form class?
0
 

Author Comment

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

Author Comment

by:jra2002
ID: 10732564
Dear Moizsaif123
I am using Windows Form
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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