Re: disallow the user to resize Columns' width in a datagrid
- From: Sergey Bogdanov <sergey.bogdanov@xxxxxxxxx>
- Date: Mon, 16 May 2005 11:44:13 +0300
Well, this solution is a bit complicated than just remove header row though it works either with a small correction:- instead of handle MouseUp event you have to write new class that derived from DataGrid, *override* method OnMouseDown then suppress base implementation for ColumnResize types. For more information see [1]. Here you are C# implementation:
public class DataGridWithFixedColumnWidth : DataGrid
{
protected override void OnMouseDown(MouseEventArgs e)
{
DataGrid.HitTestInfo hitInfo = HitTest(e.X, e.Y);
// suppress ColumnResize event
if (hitInfo.Type == DataGrid.HitTestType.ColumnResize) return;base.OnMouseDown (e); } }
[1] http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework/browse_frm/thread/99e5d7f8500d3d43/e72245ecfafa1c65#e72245ecfafa1c65
Best regards, Sergey Bogdanov http://www.sergeybogdanov.com
Arun wrote:
Write a DataGrid MouseUp event for ColumnResize and RowResize Try the code below.
private void dataGrid1_MouseUp(object sender, MouseEventArgs e) { DataGrid myGrid=(DataGrid)sender; DataGrid.HitTestInfo myHitInfo = myGrid.HitTest(e.X,e.Y);
if(myHitInfo.Type == DataGrid.HitTestType.ColumnResize) { //Do Nothing } }
Hope this helps, Cheers, Arun. www.innasite.com
.
- Follow-Ups:
- Re: disallow the user to resize Columns' width in a datagrid
- From: Joe Abou Jaoude
- Re: disallow the user to resize Columns' width in a datagrid
- References:
- disallow the user to resize Columns' width in a datagrid
- From: Joe Abou Jaoude
- Re: disallow the user to resize Columns' width in a datagrid
- From: Sergey Bogdanov
- Re: disallow the user to resize Columns' width in a datagrid
- From: Arun
- disallow the user to resize Columns' width in a datagrid
- Prev by Date: Re: disallow the user to resize Columns' width in a datagrid
- Next by Date: How to get a stack trace...
- Previous by thread: Re: disallow the user to resize Columns' width in a datagrid
- Next by thread: Re: disallow the user to resize Columns' width in a datagrid
- Index(es):