We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Displaying Unbound Column

Thread ID:

Created:

Updated:

Platform:

Replies:

95173 Jun 23,2010 06:15 PM Jun 30,2010 06:19 AM WPF 1
loading
Tags: GridControl
Mike Mann
Asked On June 23, 2010 06:15 PM

I would like to display an unbound column in my grid that is bound to a DataTable. I fill a DataTable with columns and rows based on the response from a server, I have no prior knowledge of the columns that will be in the grid. I have my binding code working correctly, all of the columns show up as they should.
My problem occurs when I try to add an unbound column. When I add the unbound column through XAML, it simply doesn't show up. All of my bound columns are displayed but the unbound column is not. When I try to add the unbound column in code, I receive an AccessViolationException, saying that I am accessing protected memory. Can you please advise?

XAML:






Code:
private void bindDataTable()
{
this.strategyOutputGrid.ItemsSource = GetDataTable();
this.VisibleRowCount = this.outputTable.DefaultView.Count;
this.strategyOutputGrid.Visibility = System.Windows.Visibility.Visible;

GridDataUnboundVisibleColumn c = new GridDataUnboundVisibleColumn();
c.HeaderText = "Selected";
this.strategyOutputGrid.VisibleColumns.Add(c);
}

Exception:
System.Reflection.TargetInvocationException was unhandled
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, 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, Boolean ignoreSyncCtx)
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, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
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 StrategyExecutor.App.Main() in C:\SRC\C#\StrategyRunner\StrategyRunner\obj\x86\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.AccessViolationException
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
InnerException:

Jeraldes J [Syncfusion]
Replied On June 30, 2010 06:19 AM

Hi Mike,

Thank you for your interest in Syncfusion products.

We have to give an Unique Mapping name for the visible column that makes your code to work successfully.

Use the below example for displaying an unbound column.

XAML:






Code:
private void bindDataTable()
{
this.strategyOutputGrid.ItemsSource = GetDataTable();
this.VisibleRowCount = this.outputTable.DefaultView.Count;
this.strategyOutputGrid.Visibility = System.Windows.Visibility.Visible;

GridDataUnboundVisibleColumn c = new GridDataUnboundVisibleColumn();
c.HeaderText = "Selected";
c.MappingName = " selected "; //Unique mapping must be given
this.strategyOutputGrid.VisibleColumns.Add(c);
}

Let us know if you need any other details.

Regards
Jeraldes J

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;