Version

FieldLength Structure

A structure that represents a unit of length supporting explicit values, sizing based on content and star values.
Syntax
'Declaration
 
Public Structure FieldLength 
   Inherits System.ValueType
public struct FieldLength : System.ValueType 
Example
The following sample demonstrates the various values that are allowed for the Width property of a Field or FieldSettings instance.

Imports Infragistics.Windows.DataPresenter

    Private Sub xamDataGrid1_Initialized(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.InitializeControl(DirectCast(sender, XamDataGrid))
    End Sub

    Private Sub InitializeControl(ByVal grid As XamDataGrid)
        Dim fl As New FieldLayout()

        ' explicit logical pixel width
        Dim fName As New Field()
        fName.Name = "name"
        fName.Width = New FieldLength(150)
        fl.Fields.Add(fName)


        ' Auto indicates that the size of the field should 
        ' grow as larger data is encountered.
        Dim fEmail As New Field()
        fEmail.Name = "email"
        fEmail.Width = FieldLength.Auto
        fl.Fields.Add(fEmail)


        ' InitialAuto indicates that the size of the field 
        ' should be based upon the initial content when the 
        ' field layout is first used.
        Dim fDept As New Field()
        fDept.Name = "department"
        fDept.Width = FieldLength.InitialAuto
        fl.Fields.Add(fDept)


        ' Pixel widths can be expressed as px (pixels, pt (Points), 
        ' in (Inches) or cm (Centimeters) just as they can in a WPF 
        ' Grid panel. Normally this is only used from within xaml 
        ' but you can create the associated type converter to use this 
        ' in code.
        '
        Dim fSalary As New Field()
        fSalary.Name = "salary"
        Dim converter As New FieldLengthConverter()
        fSalary.Width = DirectCast(converter.ConvertFromString(".5in"), FieldLength)
        fl.Fields.Add(fSalary)


        ' Star values are used to indicate a weight for the field 
        ' and is used to determine how to distribute the fields when 
        ' there is extra space or not enough. Star fields will be 
        ' increased/decreased as needed.
        '
        Dim uf1 As New UnboundField()
        uf1.Name = "Comments"
        uf1.Width = New FieldLength(1, FieldLengthUnitType.Star)
        fl.Fields.Add(uf1)

        Dim uf2 As New UnboundField()
        uf2.Name = "Notes"
        uf2.Width = New FieldLength(2, FieldLengthUnitType.Star)
        fl.Fields.Add(uf2)

        ' add the new field layout we define to the datapresenter
        grid.FieldLayouts.Add(fl)
    End Sub
using Infragistics.Windows.DataPresenter;

	private void xamDataGrid1_Initialized(object sender, EventArgs e)
	{
		this.InitializeControl(sender as XamDataGrid);
	}

	private void InitializeControl(XamDataGrid grid)
	{
		FieldLayout fl = new FieldLayout();

		// explicit logical pixel width
		Field fName = new Field();
		fName.Name = "name";
		fName.Width = new FieldLength(150);
		fl.Fields.Add(fName);


		// Auto indicates that the size of the field should  
		// grow as larger data is encountered.
		Field fEmail = new Field();
		fEmail.Name = "email";
		fEmail.Width = FieldLength.Auto;
		fl.Fields.Add(fEmail);


		// InitialAuto indicates that the size of the field 
		// should be based upon the initial content when the 
		// field layout is first used.
		Field fDept = new Field();
		fDept.Name = "department";
		fDept.Width = FieldLength.InitialAuto;
		fl.Fields.Add(fDept);


		// Pixel widths can be expressed as px (pixels, pt (Points), 
		// in (Inches) or cm (Centimeters) just as they can in a WPF 
		// Grid panel. Normally this is only used from within xaml 
		// but you can create the associated type converter to use this 
		// in code.
		//
		Field fSalary = new Field();
		fSalary.Name = "salary";
		FieldLengthConverter converter = new FieldLengthConverter();
		fSalary.Width = (FieldLength)converter.ConvertFromString(".5in");
		fl.Fields.Add(fSalary);


		// Star values are used to indicate a weight for the field 
		// and is used to determine how to distribute the fields when 
		// there is extra space or not enough. Star fields will be 
		// increased/decreased as needed.
		//
		UnboundField uf1 = new UnboundField();
		uf1.Name = "Comments";
		uf1.Width = new FieldLength(1, FieldLengthUnitType.Star);
		fl.Fields.Add(uf1);

		UnboundField uf2 = new UnboundField();
		uf2.Name = "Notes";
		uf2.Width = new FieldLength(2, FieldLengthUnitType.Star);
		fl.Fields.Add(uf2);

		// add the new field layout we define to the datapresenter
		grid.FieldLayouts.Add(fl);
	}
xmlns:igDP="http://infragistics.com/DataPresenter"

<igDP:XamDataGrid BindToSampleData="True">
    
<igDP:XamDataGrid.FieldLayouts>
        
<igDP:FieldLayout>
            
<!-- Explicit pixel widths may be specified. When the unit 
                is not specified pixels are assumed 
-->
            
<igDP:Field Name="name" Width="150"/>
            
            
<!-- Auto indicates that the size of the field should 
                grow as larger data is encountered.
-->
            
<igDP:Field Name="email" Width="Auto" />
            
            
<!-- InitialAuto indicates that the size of the field 
                should be based upon the initial content when the 
                field layout is first used. 
-->
            
<igDP:Field Name="department" Width="InitialAuto" />

            
<!-- Pixel widths can be expressed as px (pixels, 
                pt (Points), in (Inches) or cm (Centimeters) 
                just as they can in a WPF Grid panel. 
-->
            
<igDP:Field Name="salary" Width=".5in" />
            
            
<!-- Star values are used to indicate a weight for 
                the field and is used to determine how to 
                distribute the fields when there is extra 
                space or not enough. Star fields will be 
                increased/decreased as needed. 
-->
            
<igDP:UnboundField Name="Comments" Width="*" />
            
<igDP:UnboundField Name="Notes" Width="2*" />
        
</igDP:FieldLayout>
    
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also