Skupiny Google už nepodporují nová předplatná ani příspěvky Usenet. Historický obsah lze zobrazit stále.

disallow the user to resize Columns' width in a datagrid

109 zobrazení
Přeskočit na první nepřečtenou zprávu

Joe Abou Jaoude

nepřečteno,
15. 5. 2005 6:59:2715.05.05
komu:

HI,
Can I disallow the user to resize Columns' width in a datagrid ?
I fixed the width in the TableStyles.
Regards


*** Sent via Developersdex http://www.developersdex.com ***

Sergey Bogdanov

nepřečteno,
15. 5. 2005 8:15:1815.05.05
komu:
Try to hide header row:- DataGrid.RowHeadersVisible = false.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com

Arun

nepřečteno,
16. 5. 2005 3:29:3016.05.05
komu:
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

Sergey Bogdanov

nepřečteno,
16. 5. 2005 4:44:1316.05.05
komu:
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

Joe Abou Jaoude

nepřečteno,
17. 5. 2005 5:33:3217.05.05
komu:

Thankx guys, I'll try both solutions..

a question about HitTestInfo :

can i use this property to disallow a user to select a row in a datagrid
?
here's the problem:
In a datagrid that is used only in view mode,I don't want the user to be
able to change the row selections. For this purpose, I disabled the
datagrid, but the disadvantage of this method is that it prevents the
user to scroll the datagrid, and thus can't see all the records.

regards

Arun

nepřečteno,
17. 5. 2005 7:33:1917.05.05
komu:
Yes there are 8 HitTestType below is the list,
Best way is to write a class as mentioned by Sergey to disable the
datagrid.

DataGrid.HitTestType.Cell
DataGrid.HitTestType.Caption
DataGrid.HitTestType.ColumnHeader
DataGrid.HitTestType.ColumnResize
DataGrid.HitTestType.ParentRows
DataGrid.HitTestType.RowHeader
DataGrid.HitTestType.RowResize
DataGrid.HitTestType.None

block all the HitTestType each with separate condition

Joe Abou Jaoude

nepřečteno,
17. 5. 2005 8:26:3417.05.05
komu:

That's what I m gonna do...

I didn't know that HitTestType can be that useful.
that's great :)

0 nových zpráv