Hi
I want to have the ability to selected x number of cells then edit the value in the first cell and update the other cells with that value.
I have seen it done but with the winforms, Please Help
/Thomas
Hello Thomas,
I have been looking into the provided code.
According to our support policy when a sample is provided it has to be runnable, isolated in order to represent only the described behavior. All additional logic and external dependencies (such as data bases) has to be removed or replaced with a local ones for testing purposes.
Following the guidelines mentioned above, I tried to remove the parts that are not directly related to the issue, however I was not able to run the project and debug it because important parts of the code are missing and the logic cannot be applied.
As a suggestion, from what I was able to see, you try modifing the SelectedItemsChanged in the following way:
private void MediePlaner_SelectedItemsChanged(object sender, Infragistics.Windows.DataPresenter.Events.SelectedItemsChangedEventArgs e) { if (e.Type == typeof(Cell) && this.mediePlaner.SelectedItems.Cells.Count > 0 && this.mediePlaner.ActiveCell != null) { _cells.Clear(); foreach (var cell in this.mediePlaner.SelectedItems.Cells) { _cells.Add(cell); // change Cells to _cells } //.... } }
Additionally, in the provided same I was not able to see a logic for the Ctrl button in the PreviewMouseLeftButtonDown handler.
private void grid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { HitTestResult result = VisualTreeHelper.HitTest(this.grid, e.GetPosition(this.grid)); if(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { } else if (result != null && result.VisualHit != null) { //... } }
Could you please let me know whether you were able to test the previously attached sample on your side and if this is what you are looking for? If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me along with steps to reproduce. Alternatively, if the behavior cannot be replicated please feel free to provide your own sample. Remove any external dependencies and code that is not directly related to the issue, zip your application and attach it in this case.
Having a working sample on my side, which I can debug, is going to be very helpful in finding the root cause of this behavior.
Thank you for your cooperation.
Looking forward to hearing from you.
Sincerely,Teodosia HristodorovaAssociate Software Developer
Somehow when I add the last 3 lines in I can only choose one cell at the time but when I Comment it out I can choose muliple cells by holding down left mouse button but when it is comment in again I can only select the cell I
want to editMediePlan.zip
private void mediePlaner_SelectedItemsChanged(object sender, Infragistics.Windows.DataPresenter.Events.SelectedItemsChangedEventArgs e) { if (e.Type == typeof(Cell) && this.mediePlaner.SelectedItems.Cells.Count > 0 && this.mediePlaner.ActiveCell != null) { _cells.Clear(); foreach (var cell in this.mediePlaner.SelectedItems.Cells) { Cells.Add(cell); }
this.mediePlaner.SelectedItemsChanged -= this.mediePlaner_SelectedItemsChanged; CellValuePresenter.FromCell(this.mediePlaner.SelectedItems.Cells[0]).Editor.StartEditMode(); this.mediePlaner.SelectedItemsChanged += this.mediePlaner_SelectedItemsChanged; } }
Hi Teodosia
The previously attached sample works as per your requirement for selecting cells with drag selection. However, when the selection is made using Ctrl + MouseLeftButton click this will trigger the PreviewMouseLeftButtonDown event for each click and the previous SelectedItems collection will be cleared.
In order to persist the behavior for Ctrl+Click, I modified the previous sample by adding a check whether the Ctrl button is pressed in PreviewMouseLeftButtonDown handler. In this case, the behavior would not be changed.
However, keep in mind that this solution is a workaround and it's possible to not work as expected in every scenario because it's not built-in functionality. What I can suggest is submitting a new product idea at http://ideas.infragistics.com.
I have attached the modified sample below.
If you require any further assistance on the matter, please let me know.
5684.Selection_and_Editing_XamDataGrid.zip
Grid is like this and I when try to select multiple cell the first cell just getting unselected when the second is selected.
<igWPF:XamDataGrid x:Name="mediePlaner" SelectedItemsChanged="mediePlaner_SelectedItemsChanged" EditModeEnded="mediePlaner_EditModeEnded" EditModeStarting="mediePlaner_EditModeStarting" Margin="30,100,0.031,0" Grid.Row="7" VerticalAlignment="Top" Height="455" Grid.RowSpan="3" BindToSampleData="False" Grid.ColumnSpan="13" AutoFit="true" Width="Auto" PreviewMouseLeftButtonUp="mediePlaner_PreviewMouseLeftButtonUp">
<igWPF:XamDataGrid.ViewSettings> <igWPF:GridViewSettings AllowLastRecordScrollToTop="True"/> </igWPF:XamDataGrid.ViewSettings>
<igWPF:XamDataGrid.FieldSettings > <igWPF:FieldSettings AllowEdit="true" AllowGroupBy="true" AllowFixing="NearOrFar" AllowCrossFieldRecordFiltering="true" CellContentAlignment="LabelBelowValueAlignRight" AllowRecordFiltering="true" CellClickAction="SelectCell" />
</igWPF:XamDataGrid.FieldSettings>
<igWPF:XamDataGrid.FieldLayouts>
<igWPF:FieldLayout>
<igWPF:FieldLayout.SummaryDefinitions>
<igWPF:SummaryDefinition Key="unitprice_average" SourceFieldName="totalPris" Calculator="Sum" /> </igWPF:FieldLayout.SummaryDefinitions> <igWPF:FieldLayout.Settings> <igWPF:FieldLayoutSettings AutoGenerateFields="false" />
</igWPF:FieldLayout.Settings> <igWPF:TextField HorizontalContentAlignment="Left" Name="Navn" Label="Ugeavis titel" /> <igWPF:TextField LabelTextAlignment="Right" HorizontalContentAlignment="Right" Name="MmPris" Label="MmPris" Visibility="Visible" Format="####.##"/> <igWPF:TextField LabelTextAlignment="Right" HorizontalContentAlignment="Right" Name="OldMmtotal" Label="Mm Rabat" Visibility="Collapsed" Format="NO" TextAlignment="Right" /> <igWPF:TextField LabelTextAlignment="Right" HorizontalContentAlignment="Right" Name="MmRabat" Label="Mm Rabat" Visibility="Visible" Format="NO" AllowEdit="true" /> <igWPF:TextField LabelTextAlignment="Right" HorizontalContentAlignment="Right" Name="MmTotal" Label="Mm Total" Visibility="Visible" Format="NO" />
<igWPF:TextField Name="Farve4Max" Label="Farve Max" Visibility="Collapsed" Format="NO" /> <igWPF:TextField Name="Farve4Min" Label="Farve Min" Visibility="Collapsed" Format="NO"/>
<igWPF:TextField Name="FarveMax" Label="FarveMax" Visibility="Collapsed" Format="NO" /> <igWPF:TextField Name="FarveMin" Label="FarveMin" Visibility="Collapsed" Format="NO" /> <igWPF:TextField Name="FarvePris" Label="Farve Pris" HorizontalContentAlignment="Right" Visibility="Visible" Format="NO" /> <igWPF:TextField Name="FormatFra" Label="FormatFra" Visibility="Collapsed" Format="NO" /> <igWPF:TextField Name="FormatTil" Label="FormatTil" Visibility="Collapsed" Format="NO"/>
<igWPF:NumericField Name="MiljøTillæg" Label="MiljøTillæg" Visibility="Collapsed" Format="NO" ></igWPF:NumericField> <igWPF:TextField LabelTextAlignment="Right" HorizontalContentAlignment="Right" Name="FarveRabat" Label="Farve Rabat" Visibility="Visible" Format="NO"/> <igWPF:TextField LabelTextAlignment="Right" HorizontalContentAlignment="Right" Name="FarveTotal" Label="Farve Total" Visibility="Visible" Format="NO" />
<igWPF:TextField LabelTextAlignment="Right" HorizontalContentAlignment="Right" Name="totalPris" Label="Total" Visibility="Visible" Format="NO" /> <igWPF:TextField LabelTextAlignment="Right" HorizontalContentAlignment="Right" Name="TotalIncltillæg" Label="Total Incl Tillæg" Visibility="Collapsed" Format="NO" />
<igWPF:TextField LabelTextAlignment="Right" HorizontalContentAlignment="Right" Name="bemærkning" Label="bemærkning" Visibility="Visible" Format="NO" />
<igWPF:TextField Name="Adresse" Label="Adresse" Visibility="Collapsed" Format="NO"/> <igWPF:TextField Name="Adresse2" Label="Adresse2" Visibility="Collapsed" Format="NO" /> <igWPF:TextField Name="AnnonceEmail" Label="AnnonceEmail" Visibility="Collapsed" Format="NO" /> <igWPF:TextField Name="AnnonceKontrolEmail" Label="AnnonceKontrolEmail" Visibility="Collapsed" Format="NO" /> <igWPF:TextField Name="BilagsbladeEmail" Label="BilagsbladeEmail" Visibility="Collapsed" Format="NO" /> <igWPF:TextField Name="BladID" Label="BladID" Visibility="Collapsed" Format="NO" /> <igWPF:TextField Name="BogholderiEmails" Label="BogholderiEmails" Visibility="Collapsed" Format="NO" /> <igWPF:TextField Name="CVR" Label="CVR" Visibility="Collapsed" Format="NO" /> <igWPF:TextField Name="DiMPDelOmraadeKode" Label="DiMPDelOmraadeKode" Visibility="Collapsed" /> <igWPF:TextField Name="Ejerforhold" Label="Ejerforhold" Visibility="Collapsed" /> <igWPF:TextField Name="Emails" Label="Emails" Visibility="Collapsed"/> <igWPF:TextField Name="FakturaGruppeID" Label="FakturaGruppeID" Visibility="Collapsed"/> <igWPF:TextField Name="Fax" Label="Fax" Visibility="Collapsed" /> <igWPF:TextField Name="Format" Label="Format" Visibility="Collapsed" /> <igWPF:CheckBoxField Name="GiverWebTillaeg" Label="GiverWebTillaeg" Visibility="Collapsed"/> <igWPF:TextField Name="GruppeRabat" Label="GruppeRabat" Visibility="Collapsed" /> <igWPF:TextField Name="Hjemmeside" Label="Hjemmeside" Visibility="Collapsed" /> <igWPF:TextField Name="Koncern" Label="Koncern" Visibility="Collapsed"/> <igWPF:TextField Name="Kontaktperson" Label="Kontaktperson" Visibility="Collapsed"/> <igWPF:TextField Name="KontaktpersonerEmails" Label="KontaktpersonerEmails" Visibility="Collapsed"/> <igWPF:TextField Name="MaterialedeadlineRubrik" Label="MaterialedeadlineRubrik" Visibility="Collapsed" /> <igWPF:TextField Name="MaterialeDeadlineRubrikDag" Label="MaterialeDeadlineRubrikDag" Visibility="Collapsed" /> <igWPF:TextField Name="MaterialeDeadlineRubrikKl" Label="MaterialeDeadlineRubrikKl" Visibility="Collapsed" /> <igWPF:TextField Name="MaterialedeadlineTekst" Label="MaterialedeadlineTekst" Visibility="Collapsed" /> <igWPF:TextField Name="MaterialeDeadlineTekstDag" Label="MaterialeDeadlineTekstDag" Visibility="Collapsed"/> <igWPF:TextField Name="MaterialeDeadlineTekstKl" Label="MaterialeDeadlineTekstKl" Visibility="Collapsed" /> <igWPF:TextField Name="MaterialeEmail" Label="MaterialeEmail" Visibility="Collapsed"/> <igWPF:TextField Name="MatGodtBeloeb" Label="MatGodtBeloeb" Visibility="Collapsed" /> <igWPF:TextField Name="MedlemMaaned" Label="MedlemMaaned" Visibility="Collapsed"/> <igWPF:TextField Name="Medlemaar" Label="Medlemaar" Visibility="Collapsed"/> <igWPF:CheckBoxField Name="MaaGiveFarveRabat" Label="MaaGiveFarveRabat" Visibility="Collapsed"/>
<igWPF:TextField Name="Navn2" Label="Navn2" Visibility="Collapsed" /> <igWPF:CheckBoxField Name="Ophoert" Label="Ophoert" Visibility="Collapsed" /> <igWPF:TextField Name="OrdrecheckEmail" Label="OrdrecheckEmail" Visibility="Collapsed" /> <igWPF:TextField Name="OrdrecheckSendeDagID" Label="OrdrecheckSendeDagID" Visibility="Collapsed"/> <igWPF:TextField Name="OrdredeadlineRubrik" Label="OrdredeadlineRubrik" Visibility="Collapsed"/> <igWPF:TextField Name="OrdreDeadlineRubrikDag" Label="OrdreDeadlineRubrikDag" Visibility="Collapsed"/> <igWPF:TextField Name="OrdreDeadlineRubrikKl" Label="OrdreDeadlineRubrikKl" Visibility="Collapsed" /> <igWPF:TextField Name="OrdredeadlineTekst" Label="OrdredeadlineTekst" Visibility="Collapsed" /> <igWPF:TextField Name="OrdreDeadlineTekstDag" Label="OrdreDeadlineTekstDag" Visibility="Collapsed" /> <igWPF:TextField Name="OrdreDeadlineTekstKl" Label="OrdreDeadlineTekstKl" Visibility="Collapsed" /> <igWPF:TextField Name="OrdreEmail" Label="OrdreEmail" Visibility="Collapsed"/> <igWPF:TextField Name="OrienteringEmails" Label="OrienteringEmails" Visibility="Collapsed" /> <igWPF:CheckBoxField Name="Overfoert" Label="Overfoert" Visibility="Collapsed"/> <igWPF:TextField Name="Primaer" Label="Primaer" Visibility="Collapsed"/> <igWPF:TextField Name="PrimaerPct" Label="PrimaerPct" Visibility="Collapsed"/> <igWPF:TextField Name="PrisforespoergselEmails" Label="PrisforespoergselEmails" Visibility="Collapsed"/> <igWPF:TextField Name="RedaktionEmail" Label="RedaktionEmail" Visibility="Collapsed"/> <igWPF:TextField Name="SamannonceringsRabat" Label="SamannonceringsRabat" Visibility="Collapsed"/> <igWPF:TextField Name="SendetidOrdrecheck" Label="SendetidOrdrecheck" Visibility="Collapsed" /> <igWPF:CheckBoxField Name="SendIndevaerendeUge" Label="SendIndevaerendeUge" Visibility="Collapsed"/> <igWPF:TextField Name="StamdataEmail" Label="StamdataEmail" Visibility="Collapsed" /> <igWPF:TextField Name="Tlf" Label="Tlf" Visibility="Collapsed" /> <igWPF:TextField Name="Totalomraade" Label="Totalomraade" Visibility="Collapsed" /> <igWPF:TextField Name="TotalomraadePct" Label="TotalomraadePct" Visibility="Collapsed"/> <igWPF:CheckBoxField Name="VisPaaWWW" Label="VisPaaWWW" Visibility="Collapsed"/>
<igWPF:TextField Name="RegionNavn" Label="Region Navn" Visibility="Collapsed" /> <igWPF:TextField Name="DaekningsGrad" Label="Dæknings Grad" Visibility="Collapsed"/> <igWPF:TextField Name="Oplag" Label="Oplag" Visibility="Collapsed" /> <igWPF:TextField Name="DagNavn" Label="DagNavn" Visibility="Collapsed" /> <igWPF:TextField Name="GeoKodeNavn" Label="GeoKodeNavn" Visibility="Collapsed" /> <igWPF:TextField Name="HovedGruppeNavn" Label="HovedGruppeNavn" Visibility="Collapsed" /> <igWPF:TextField Name="Husstande" Label="Husstande" Visibility="Collapsed" /> <igWPF:TextField Name="MaxDaekningsGrad" Label="MaxDaekningsGrad" Visibility="Collapsed" /> <igWPF:TextField Name="PostBy" Label="PostBy" Visibility="Collapsed"/> <igWPF:TextField Name="PostNr" Label="PostBy" Visibility="Collapsed"/> <igWPF:TextField Name="Betegnelse" Label="Betegnelse" Visibility="Collapsed"/> <igWPF:TextField Name="PrislisteNavn" Label="PrislisteNavn" Visibility="Collapsed" />
</igWPF:FieldLayout>
</igWPF:XamDataGrid.FieldLayouts>
<igWPF:XamDataGrid.FieldLayoutSettings> <igWPF:FieldLayoutSettings HeaderPrefixAreaDisplayMode="Menu" HeaderPrefixAreaMenuOptions="Default" FilterUIType="Default"/> </igWPF:XamDataGrid.FieldLayoutSettings> </igWPF:XamDataGrid>