Highlighted
Absent Member.
Absent Member.
738 views

Wpf Datagrid read thru

Have a datagrid that I built and would like to read thru the entire grid after its populated to print all the data on a report.

             <DataGrid x:Name="dataGrid1"
                              ItemsSource="{Binding}"
                              MouseDoubleClick="DataGrid_MouseDoubleClick"
                              SelectionMode="Extended"
                <DataGrid.Columns>
                  <!--Vendor-->
                  <DataGridTextColumn MinWidth="50" Binding="{Binding Path=Vs_Vnd, Mode=TwoWay}" Header= "Vendor" />
                  <!--Ap Name-->
                  <DataGridTextColumn MinWidth="100" Binding="{Binding Path=AP_Name, Mode=OneWay}" Header= "Name"/>
                  <!--Sku #-->
                  <DataGridTextColumn MinWidth="140" Binding="{Binding Path=Vs_Sku, Mode=TwoWay}" Header= "Sku#"/>
                  <!--Lt Product Code -->
                  <DataGridTextColumn MinWidth="70" Binding="{Binding Path=Vs_Pc_Lin, Mode=OneWay}" Header= "Lt Product Code"/>
                  <!--Description-->
                  <DataGridTextColumn MinWidth="400" Binding="{Binding Vs_Desc, Mode=OneWay}" Header= "Description"/>
                  <!--count-->
                  <DataGridTextColumn MinWidth="50" Binding="{Binding Vs_Edm_Count, Mode=OneWay}" Header= "Rcvd"/>
                  <!--Product Type-->
                  <DataGridTextColumn MinWidth="40" Binding="{Binding Vs_Product_Type, Mode=TwoWay}" Header= "Type"/>
                  <!--Descriptor1-->
                  <DataGridTextColumn MinWidth="120" Binding="{Binding Vs_Descriptor1, Mode=TwoWay}" Header= "Descriptor1"/>
                  </DataGrid.Columns>
              </DataGrid>

 

I use this routine to read thru after I have highlight some records, but unsure how to read the datagrid from top to bottom.

           set Ws-Count to DataGrid1::SelectedItems::Count
          
           if DataGrid1::SelectedItems::Count > 0
              perform varying selectedRow as type myRow thru DataGrid1::SelectedItems
                 set Ws-Sku-Number            to selectedRow::Vs_Sku   
                 set Ws-Vendor-Number       to type System.Convert::ToInt32(selectedRow::Vs_Vnd)
                 set ws-ap-name                  to selectedRow::AP_Name
                
                 set currentItemText01 to type System.Convert::ToInt32(selectedRow::Vs_Vnd)
                 set currentItemText02 to selectedRow::AP_Name
                 set currentItemText03 to selectedRow::Vs_Sku
                 set currentItemText04 to selectedRow::Vs_Desc
                 set currentItemText05 to selectedRow::Vs_Edm_Count
                 
                 set LUMBR to new PurchasingPortal.Window11
                 set LUMBR::TextBlock1::Text to currentItemText01    *> Vendor #
                 set LUMBR::TextBlock2::Text to currentItemText02    *> Vendor Name
                 set LUMBR::TextBlock3::Text to currentItemText03    *> Sku #
                 set LUMBR::TextBlock4::Text to currentItemText04    *> Decsription
                 set LUMBR::TextBlock5::Text to currentItemText05    *> # Times
          
                 INVOKE LUMBR::ShowDialog()
                
              end-perform
           end-if

Thanks

 

 

       class-id myRow.
       working-storage section.
       01 Vs_Vnd           decimal property.
       01 AP_Name          string property.
       01 Vs_Sku           string property.
       01 Vs_Product_Type  string property.
       01 Vs_Pc_Lin        string property.
       01 Vs_Desc          string property.
       01 Vs_Descriptor1   string property.
       01 Vs_Edm_Count     decimal property.
       01 Vs_Desc_Chg_Dt   string property.
       01 Vs_Desc_Chg_By   string property.

Tags (1)
0 Likes
2 Replies
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: Wpf Datagrid read thru

Hi Mark
You write that you want to print the entire grid but your code looks like you want to display a dialog. The code looks like the example I sent you in march this year. I have the solution still on my system. How can I help you?
Freundliche Grüsse
Werner Lanter
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: Wpf Datagrid read thru

Enhancement of my example for getting all rows:
method-id buttonAll_Click.
procedure division using by value sender as object e as type System.Windows.RoutedEventArgs.
invoke listBox1::Items::Clear

declare selectedRow as type myRow
declare i1 as binary-long
perform varying i1 from 0 by 1 until i1 >= dataGrid1::Items::Count
set selectedRow to dataGrid1::Items::GetItemAt(i1) as type myRow *> gets all rows in display order
invoke listBox1::Items::Add(selectedRow::Vs_Vnd::ToString & " " & selectedRow::Vs_Desc)
end-perform

end method.
Freundliche Grüsse
Werner Lanter
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.