Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1655
Adding textbox in infragistics WPF grid and assigning value to it dynamically
posted

I have a textbox placed in infragistic grid. i want to assign value to it. How to do it?i want to assign the value programmatically..Each textbox in each row of the grid will display different value.

Code for the textbox in grid:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<igDP:XamDataGrid Name="dgAvailableResults" Grid.Row="1" Grid.Column="3"

 

 

TabIndex="7" HorizontalAlignment="Center" Width="440" MaxHeight="340" DataSource="{Binding}"

 

 

Style="{StaticResource InfragisticsGrid}" >

 

 

 

<igDP:XamDataGrid.Resources>

 

 

 

<Style TargetType="{x:Type igDP:LabelPresenter}">

 

 

 

<Setter Property="Background" Value="#D3D3D3"/>

 

 

 

<Setter Property="Foreground" Value ="#000000"/>

 

 

 

<Setter Property="FontWeight" Value="Bold"/></Style>

 

 

 

<Style TargetType="{x:Type igDP:CellValuePresenter}">

 

 

 

<Setter Property="HorizontalContentAlignment" Value="Left" />

 

 

 

<Style.Triggers>

 

 

 

<DataTrigger Binding="{Binding Path=StaffData, RelativeSource={RelativeSource Self}}"

 

 

Value

="StaffData"><Setter Property="HorizontalContentAlignment" Value="Left" />

 

 

 

</DataTrigger></Style.Triggers></Style>

 

 

 

<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="gridtext">

 

 

 

<Setter Property="Template"><Setter.Value>

 

 

 

<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

 

 

 

<Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" >

 

 

 

<TextBox x:Name="txtNew" HorizontalAlignment="Right"

 

 

Style="{StaticResource txtBoxDefault}" />

 

 

 

</Grid>

 

 

 

</ControlTemplate></Setter.Value></Setter></Style>

 

 

 

 

 

 

</igDP:XamDataGrid.Resources>

 

 

 

<igDP:XamDataGrid.FieldSettings>

 

 

 

<igDP:FieldSettings AllowRecordFiltering="true"/>

 

 

 

</igDP:XamDataGrid.FieldSettings>

 

 

 

<igDP:XamDataGrid.FieldLayoutSettings><igDP:FieldLayoutSettings FilterUIType="FilterRecord"

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

AutoGenerateFields="False" HighlightAlternateRecords="True" />

 

 

 

</igDP:XamDataGrid.FieldLayoutSettings>

 

 

 

<igDP:XamDataGrid.FieldLayouts>

 

 

 

<igDP:FieldLayout>

 

 

 

<igDP:FieldLayout.Fields>

 

 

 

<igDP:Field Name="StaffName" Label="Staff NAME">

 

 

 

<igDP:Field.Settings>

 

 

 

<igDP:FieldSettings AllowEdit="False" CellWidth="150" LabelWidth="150"

 

 

CellClickAction ="SelectRecord"LabelTextAlignment ="Left"/>

 

 

 

</igDP:Field.Settings>

 

 

 

</igDP:Field>

 

 

 

<igDP:Field Name="StaffNo">

 

 

 

<igDP:Field.Settings>

 

 

 

<igDP:FieldSettings>

 

 

 

<igDP:FieldSettings.CellValuePresenterStyle>

 

 

 

<Style TargetType="{x:Type igDP:CellValuePresenter}">

 

 

 

<Setter Property="Template"><Setter.Value>

 

 

 

<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

 

 

 

<TextBox></TextBox>

 

 

 

</ControlTemplate>

 

 

 

</Setter.Value>

 

 

 

</Setter>

 

 

 

</Style>

 

 

 

</igDP:FieldSettings.CellValuePresenterStyle>

 

 

 

</igDP:FieldSettings>

 

 

 

</igDP:Field.Settings>

 

 

 

</igDP:Field>

 

 

 

<igDP:Field Name="Address" Label="Address">

 

 

 

<igDP:Field.Settings>

 

 

 

<igDP:FieldSettings AllowEdit="False" CellWidth="150" LabelWidth="150"

 

 

CellClickAction="SelectRecord"LabelTextAlignment="Left"/>

 

 

 

</igDP:Field.Settings>

 

 

 

</igDP:Field>

 

 

 

</igDP:FieldLayout.Fields>

 

 

 

</igDP:FieldLayout>

 

 

 

</igDP:XamDataGrid.FieldLayouts>

 

 

 

</igDP:XamDataGrid>

 

Parents
  • 69686
    posted

    Hello,

    If you want to access an element inside the cell, you have to get the CellValuePresenter first and then find the element inside. The CVP you can get with the CellValuePresenter.FromCell method and then use the utilities methods to find the textbox:

    TextBox textBox= Infragistics.Windows.Utilities.GetDescendantFromType

        (

        myCellValuePresenter,

        typeof(TextBox ),

        false

        

    as TextBox;

Reply Children
No Data