We have a RadGridView with 2 columns.
When we edit a cell or when we are adding a new row, we want to loop through the rows cell[1] to check for duplicates.
We want to do this in...
private void TheGridCellValidating(object sender, GridViewCellValidatingEventArgs e).
We try things like this...
var grid = (e.Row).GridViewDataControl;
string value = e.NewValue.ToString();
var rows = grid.ChildrenOfType<GridViewRow>();
foreach (var row in rows)
{
if (row == null) continue;
if (row.Cells == null) continue;
if (row.Cells[1] != null)
{
var s = row.Cells[0]......
...
....
}
}
But... it won't work.
How can we iterate on the rows and check for duplicates?
System.FormatException was unhandled
Message=Input string was not in a correct format.
Source=Telerik.Windows.Controls.DataVisualization
StackTrace:
at Telerik.Windows.Controls.Map.Location.Parse(String source) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q1_SP2\Sources\Development\Controls\DataVisualization\Map\Location.cs:line 200
at Telerik.Windows.Controls.Map.LocationConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q1_SP2\Sources\Development\Controls\DataVisualization\Map\LocationConverter.cs:line 40
at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
at Telerik.Windows.Controls.Map.InformationLayer.GetLocationFromItem(Object item) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q1_SP2\Sources\Development\Controls\DataVisualization\Map\Layers\InformationLayer.cs:line 1214
at Telerik.Windows.Controls.Map.InformationLayer.PrepareContainerForItemOverride(DependencyObject element, Object item) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q1_SP2\Sources\Development\Controls\DataVisualization\Map\Layers\InformationLayer.cs:line 449
at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
at System.Windows.Controls.Panel.reGenerateChildren()
at System.Windows.Controls.Panel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args)
at System.Windows.Controls.Panel.OnItemsChanged(Object sender, ItemsChangedEventArgs args)
at System.Windows.Controls.ItemContainerGenerator.OnRefresh()
at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Data.ListCollectionView.RefreshOverride()
at System.Windows.Data.CollectionView.RefreshInternal()
at System.Windows.Data.CollectionView.Refresh()
at System.Windows.Data.CollectionView.EndDefer()
at System.Windows.Data.CollectionView.DeferHelper.Dispose()
at System.Windows.Controls.ItemCollection.SetCollectionView(CollectionView view)
at System.Windows.Controls.ItemCollection.SetItemsSource(IEnumerable value)
at System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
at System.Windows.Data.BindingExpression.Invalidate(Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.Activate(Object item)
at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Run(Object arg)
at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e)
at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.UIElement.UpdateLayout()
at System.Windows.Interop.HwndSource.SetLayoutSize()
at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
at System.Windows.Window.SetRootVisual()
at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
at System.Windows.Window.CreateSourceWindowImpl()
at System.Windows.Window.SafeCreateWindow()
at System.Windows.Window.ShowHelper(Object booleanBox)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at WpfApplication1.App.Main() in C:\Users\frederic.souchu\documents\visual studio 2010\Projects\WpfMap\WpfApplication1\obj\x86\Release\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.FormatException
Message=Input string was not in a correct format.
Source=Telerik.Windows.Controls.DataVisualization
StackTrace:
at Telerik.Windows.Controls.Map.Location.Parse(String source) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q1_SP2\Sources\Development\Controls\DataVisualization\Map\Location.cs:line 185
InnerException:
<telerik:RadCarousel x:Name="carousel"> |
<Image Source="Images/Puck/1.jpg" Width="200" Height="200" Stretch="Fill" /> |
<Image Source="Images/Puck/4.jpg" Width="200" Height="200" Stretch="Fill" /> |
<Image Source="Images/Puck/5.jpg" Width="200" Height="200" Stretch="Fill" /> |
<Image Source="Images/Puck/6.jpg" Width="200" Height="200" Stretch="Fill" /> |
<Image Source="Images/Puck/7.jpg" Width="200" Height="200" Stretch="Fill" /> |
<Image Source="Images/Puck/9.jpg" Width="200" Height="200" Stretch="Fill" /> |
<Image Source="Images/Puck/10.jpg" Width="200" Height="200" Stretch="Fill" /> |
<Image Source="Images/Puck/11.jpg" Width="200" Height="200" Stretch="Fill" /> |
</telerik:RadCarousel> |
<Grid.Resources> |
<Style TargetType="{x:Type telerik:CarouselItem}"> |
<Setter Property="Template"> |
<Setter.Value> |
<ControlTemplate TargetType="{x:Type telerik:CarouselItem}"> |
<Border x:Name="border"> |
<VisualStateManager.VisualStateGroups> |
<VisualStateGroup x:Name="ValidationStates"> |
<VisualState x:Name="Valid"/> |
<VisualState x:Name="InvalidFocused"/> |
<VisualState x:Name="InvalidUnfocused"/> |
</VisualStateGroup> |
</VisualStateManager.VisualStateGroups> |
<Border x:Name="CarouselItemMainBorder" |
ClipToBounds="False" RenderTransformOrigin="0.5, 1" |
Opacity="{Binding ReflectionSettings.Opacity, RelativeSource={RelativeSource TemplatedParent}}" |
Visibility="{Binding ReflectionSettings.Visibility, RelativeSource={RelativeSource TemplatedParent}}" |
BorderBrush="{x:Null}" BorderThickness="1,1,1,1" CornerRadius="0" SnapsToDevicePixels="True" Margin="0,0,-10,-35" MouseEnter="MouseEnterTest"> |
<Border.Background> |
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> |
<GradientStop Color="#FFC1DCFF" Offset="0"/> |
<GradientStop Color="#FF7EB8F8" Offset="1"/> |
</LinearGradientBrush> |
</Border.Background> |
</Border> |
</Border> |
</ControlTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
</Grid.Resources> |
public class Data |
{ |
public UInt32 XValue { get; set; } |
public double YValue { get; set; } |
} |
List<Data> m_Data; // This is initialized with data. |
// Then, when setting up the chart... |
SeriesMapping seriesMapping = new SeriesMapping(); |
LineSeriesDefinition lineDefinition = new LineSeriesDefinition(); |
lineDefinition.ShowItemLabels = false; |
seriesMapping.SeriesDefinition = lineDefinition; |
seriesMapping.ItemMappings.Add(new ItemMapping("XValue", DataPointMember.XValue)); |
seriesMapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue)); |
MyChart.SeriesMappings.Add(seriesMapping); |
// Then I set my data |
MyChart.ItemSource = m_Data; |