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
160
adding textbox and Lookup button in a single column in Infagistics grid and populating the textbox on selecting a row in lookup button click
posted

Hi,

I am working on Infragistics Datagrid (V 10.2), I have a field that contains a TextBox and a Lookup Button that popsup a window with a table of 3 other columns on button click  event. I am good till this.

But my problem here is, when i select a row in popup window, all the vales in the three fields of the popup window should be binded to the textbox beside the lookup button and other two fields in the infragistics grid.

These are the styles I wrote for Button and TextBox: 

 

 

 

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

 

 

 

<Setter Property="ContentTemplate">

 

 

 

<Setter.Value>

 

 

 

<DataTemplate>

 

 

 

<DockPanel>

 

 

 

<igRibbon:ButtonTool Height="22" DockPanel.Dock="Right" Name="btnGridLookUp" SmallImage="/Images/Lookup.png" ToolTip="LookUp" Width="27" Click="btnGridLookUp_Click">

<igRibbon:ButtonTool.BitmapEffect>

 

 

 

 

<BitmapEffectGroup>

 

 

 

 

<DropShadowBitmapEffect />

 

 

 

 

</BitmapEffectGroup>

 

 

 

 

</igRibbon:ButtonTool.BitmapEffect>

 

 

 

 

</igRibbon:ButtonTool>

 

 

 

 

<ContentPresenter Content="{TemplateBinding Content}"/>

 

 

 

 

</DockPanel>

 

 

 

 

</DataTemplate>

 

 

 

 

</Setter.Value>

 

 

 

 

</Setter>

 

 

 

 

</Style>

 

 

 

 

<Style TargetType="{x:Type igEditors:XamTextEditor}" x:Key="TextStyle">

 

 

 

 

<Setter Property="Background" Value="Transparent" />

</Style>

This is how I binded them to Grid:

 

 

 

 

 

 

 

<igDP:Field Name="Col3" Label="TestSample" Width="80">

 

 

 

<igDP:Field.Settings>

 

 

 

<igDP:FieldSettings CellValuePresenterStyle="{StaticResource SearchButtonFieldStyle}" EditorStyle="{StaticResource TextStyle}"/>

 

 

 

</igDP:Field.Settings>

 

 

 

</igDP:Field>

Here I am not sure of how to access/bind a value to the textbox beside the button.

Please advise.

Thanks,

Rakesh

Parents
No Data
Reply
  • 12875
    posted

     Hi Rakesh,

     I used this code in the button click event to search the visual tree looking for the cellValuePresenter.  Then I can get to the record and use all of the cell values.

    I think this is what you need to value the pop up window.  

    private void btnGridLookUp_Click(object sender, RoutedEventArgs e)
    {
     Debug.WriteLine("btnGridLookUp_Click");

     ButtonTool bt = sender as  ButtonTool;

     DependencyObject dp = VisualTreeHelper.GetParent(bt);
     if (dp.GetType() != typeof(CellValuePresenter))
     {
      while (dp != null && dp.GetType() != typeof(CellValuePresenter))
      {
       dp = VisualTreeHelper.GetParent(dp);
      }
     }
     if (dp != null )
     {
      CellValuePresenter cvp = dp as CellValuePresenter;
      DataRecord dr = cvp.Record as DataRecord;

      for (int i = 0; i < dr.Cells.Count - 1; i++)
      {
       Debug.WriteLine("Cell" + i.ToString() + " " + dr.Cells[i].Value.ToString());
      }
     }
    }

    
    

     

    Please let me know if you have any questions.

     

    
    

Children