Type | Description | |||
Boolean | A boolean expression that indicates whether the column is automatically resized according to the width of the contents within the column. |
Use the WidthAutoResize property if you need to display the entire caption of each cell in the column. If the WidthAutoResize property is True, the user is not able to resize the column, so the AllowSizing property has no effect in this case. Use the ColumnAutoResize property to specify whether the control resizes the visible columns so they fit the control's client area. You can use the AutoWidth property to computes the column's width to fit its content. For instance, if you have a tree with one column, and this property True, you can simulate a simple tree, because the control will automatically add a horizontal scroll bar when required. Use the HeaderVisible property to hide the control's header bar. Use the BeginUpdate and EndUpdate method to maintain performance while adding columns and items to the control. Use the MinWidthAutoResize property to specify the minimum column width, while the WidthAutoResize property is True.
The following VB sample adds a single column that's resized when the user expands or collapses an item:
Private Sub Form_Load() With Grid1 .BeginUpdate .LinesAtRoot = True .Columns.Add("Column1").WidthAutoResize = True With .Items Dim h As HITEM h = .AddItem("Item 1") .InsertItem h, , "Item 2" h = .InsertItem(h, , "Item 3") .ExpandItem(.FindItem("Item 1")) = True End With .EndUpdate End With End Sub
The following C++ sample adds a single column that's resized when the user expands or collapses an item:
#include "Items.h" #include "Column.h" #include "Columns.h" COleVariant vtMissing; V_VT( &vtMissing) = VT_ERROR; m_grid.BeginUpdate(); m_grid.SetLinesAtRoot( 1 ); CColumn column( V_DISPATCH( &m_grid.GetColumns().Add( "Column 1" ) ) ); column.SetWidthAutoResize( TRUE ); CItems items = m_grid.GetItems(); long hItem = items.AddItem( COleVariant( "Item 1" ) ); hItem = items.InsertItem( hItem, vtMissing, COleVariant( "Item 2" ) ); items.InsertItem( hItem, vtMissing, COleVariant( "Item 3" ) ); items.SetExpandItem( items.GetFindItem(COleVariant("Item 1"), vtMissing, vtMissing), TRUE ); m_grid.EndUpdate();
The following VB.NET sample adds a single column that's resized when the user expands or collapses an item:
With AxGrid1 .BeginUpdate() .LinesAtRoot = EXGRIDLib.LinesAtRootEnum.exLinesAtRoot .Columns.Add("Column1").WidthAutoResize = True With .Items Dim h As Integer = .AddItem("Item 1") .InsertItem(h, , "Item 2") h = .InsertItem(h, , "Item 3") .ExpandItem(.FindItem("Item 1")) = True End With .EndUpdate() End With
The following C# sample adds a single column that's resized when the user expands or collapses an item:
axGrid1.BeginUpdate(); axGrid1.LinesAtRoot = EXGRIDLib.LinesAtRootEnum.exLinesAtRoot; EXGRIDLib.Column column = axGrid1.Columns.Add("Column 1") as EXGRIDLib.Column ; column.WidthAutoResize = true; EXGRIDLib.Items items = axGrid1.Items; int hItem = items.AddItem("Item 1"); hItem = items.InsertItem(hItem, null, "Item 2"); items.InsertItem(hItem, null, "Item 2"); items.set_ExpandItem(items.get_FindItem("Item 1", null, null), true); axGrid1.EndUpdate();
The following VFP sample adds a single column that's resized when the user expands or collapses an item:
with thisform.Grid1 .BeginUpdate() .LinesAtRoot = .t. .Columns.Add("Column1").WidthAutoResize = .t. With .Items local h h = .AddItem("Item 1") .InsertItem(h, , "Item 2") h = .InsertItem(h, , "Item 3") .DefaultItem = .FindItem("Item 1") .ExpandItem(0) = .t. EndWith .EndUpdate() endwith