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
460
Get selected cell or records on mouse release
posted

I have this  XamGrid  and I would like to know which action to implement get the choosen cells or records when left mouse buttom is relased. 

<igWPF:XamDataGrid DataSource="{Binding Path=observale, Mode=OneWayToSource}" VerticalAlignment="Top" Name="dgAktiveAviser" SelectedDataItemsScope="RecordsOrCells" IsUndoEnabled="True" MouseUp="dgAktiveAviser_MouseUp"
>
<igWPF:XamDataGrid.FieldSettings >
<igWPF:FieldSettings AllowCrossFieldRecordFiltering="true" AllowRecordFiltering="true" CellClickAction="SelectCell" />
</igWPF:XamDataGrid.FieldSettings>

<igWPF:XamDataGrid.FieldLayouts>

<igWPF:FieldLayout>

<igWPF:FieldLayout.CrossFieldRecordFilters>
<igWPF:CrossFieldRecordFilterGroup LogicalOperator="And">
<igWPF:CrossFieldRecordFilterGroup LogicalOperator="Or">
<igWPF:CrossFieldRecordFilter FieldName="Navn" Operator="Equals" Operand="UK" />
<igWPF:CrossFieldRecordFilter FieldName="Adresse" Operator="Equals" Operand="USA" />
</igWPF:CrossFieldRecordFilterGroup>
<igWPF:CrossFieldRecordFilter FieldName="ContactName" Operator="StartsWith" Operand="A" />
</igWPF:CrossFieldRecordFilterGroup>
</igWPF:FieldLayout.CrossFieldRecordFilters>
<igWPF:TextField Name="BladID" Label="Blad ID2" Visibility="Hidden">

</igWPF:TextField>

<igWPF:TextField Name="Navn" Label="Navn" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="Adresse" Label="Adresse" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="PostNr" Label="Post Nummer" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="PostBy" Label="Post By" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="Tlf" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="CVR" Label="CVR" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="Kontaktperson" Label="Kontakt Person" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="HovedGruppeNavn" Label="Hoved Gruppe" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="MedlemMåned" Label="Medlem Måned"></igWPF:TextField>
<igWPF:TextField Name="MedlemÅr" Label="Medlem År"></igWPF:TextField>
<igWPF:TextField Name="Ejerforhold" Label="Ejerforhold" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="RegionNavn" Label="Region Navn" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="DelOmrådeNavn" Label="Delområde" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="DIMPDelOmrådeKode" Label="DIMPDelOmrådeKode" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="GeoKodeNavn" Label="Geo kode navn" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="Totalområde" Label="Total område" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="TotalområdePct" Label="Total område %" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="Primær" Label="Primær" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="PrimærPct" Label="Primær %" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="WWWDækninSomTekst" Label="WWW Dækning som tekst" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="Oplag" Label="Oplag" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="Udgivelsesdag" Label="Udgivelses dag" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="Format" Label="Format" Visibility="Visible"></igWPF:TextField>
<igWPF:TextField Name="OrdredeadlineTekst" Label="Ordredeadline" Visibility="Visible"></igWPF:TextField>
<igWPF:CheckBoxField Name="OrdredeadlineRubrik" Label="OrdreDeadline"></igWPF:CheckBoxField>
<igWPF:TextField Name="MaterialedeadlineTekst" Label="Materiale deadline"></igWPF:TextField>
<igWPF:CheckBoxField Name="MaterialedeadlineRubrik" Label="Materiale deadline"></igWPF:CheckBoxField>
<igWPF:TextField Name="OrdreEmail" Label="Ordre Email" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="OrdrecheckEmail" Label="Ordre Check Email"></igWPF:TextField>
<igWPF:TextField Name="DagNavn" Label="Dag Navn"></igWPF:TextField>
<igWPF:CheckBoxField Name="SendetidOrdrecheck" Label="Sennde tid"></igWPF:CheckBoxField>
<igWPF:TextField Name="SendIndeværendeUge" Label="Send IndeværendeUge"></igWPF:TextField>
<igWPF:TextField Name="StamdataEmail" Label="StamdataEmail"></igWPF:TextField>
<igWPF:TextField Name="PrisforespørgselEmails" Label="PrisforespørgselEmails"></igWPF:TextField>
<igWPF:TextField Name="OrienteringEmails" Label="OrienteringEmails"></igWPF:TextField>
<igWPF:TextField Name="Emails" Label="Emails"></igWPF:TextField>
<igWPF:TextField Name="KontaktpersonerEmails" Label="KontaktpersonerEmails" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="BogholderiEmails" Label="BogholderiEmails" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="MedieNetKode" Label="MedieNetKode" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="Hjemmeside" Label="Hjemmeside" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="RedaktionEmail" Label="RedaktionEmail" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="AnnonceEmail" Label="AnnonceEmail" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="MaterialeEmail" Label="MaterialeEmail" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="AnnonceKontrolEmail" Label="AnnonceKontrolEmail" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="BilagsbladeEmail" Label="BilagsbladeEmail" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="GruppeNavn" Label="GruppeNavn" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="GruppeRabat" Label="GruppeRabat" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="SamannonceringsRabat" Label="SamannonceringsRabat" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="HovedgruppeID" Label="HovedgruppeID" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="Ophørt" Label="Ophørt" Visibility="Hidden"></igWPF:TextField>
<igWPF:TextField Name="Version" Label="Version" Visibility="Hidden"></igWPF:TextField>


</igWPF:FieldLayout>

</igWPF:XamDataGrid.FieldLayouts>


<igWPF:XamDataGrid.FieldLayoutSettings>
<igWPF:FieldLayoutSettings HeaderPrefixAreaDisplayMode="Menu" HeaderPrefixAreaMenuOptions="Default" FilterUIType="Default"/>
</igWPF:XamDataGrid.FieldLayoutSettings>
</igWPF:XamDataGrid>

Parents
  • 1560
    Offline posted
    Hello Thomas,

    Thank you for the code-snippet you have provided.

    My suggestion is to handle the PreviewMouseLeftButtonUp event. It fires every time left mouse button is released. In the event handler, the content of SelectedItems property could be checked. This collection holds collections of selected cells and selected records, and from there you can get their values and use it per your needs.
     private void Grid_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
            {
                var selectedItems = (sender as XamDataGrid).SelectedItems;
                if(selectedItems.Cells.Count != 0)   
                {
                      //get selected cells from selectedItems.Cells
                }
                else if(selectedItems.Records.Count != 0) 
                {
                      //get selected records from selectedItems.Records
                }
            }
    I have attached a sample application that uses the suggested approach. Please test it on your side and let me know if I may be of any further assistance.
    Sincerely,
    Teodosia Hristodorova
    Associate Software Developer
Reply Children
No Data