Group: Forum Members
Last Active: 13 Years Ago
Posts: 22,
Visits: 1
|
Hi,
I have a data table bound to an NTreeList via an NTreeListTableData object. Right after I bind the data, I set some additional property values on the NTreeListColumns like this:
NTreeListTableData data = new NTreeListTableData(); data.Table = _dtHoldings; data.Bind(dgHoldings);
foreach (DataColumn dc in _dtHoldings.Columns) { NTreeListColumn col = dgHoldings.Columns[dc.ColumnName]; col.Width = int.Parse(dc.ExtendedProperties["width"].ToString()); col.Visible = bool.Parse(dc.ExtendedProperties["isVisible"].ToString()); col.ContentAlign = (ContentAlignment)dc.ExtendedProperties["contentAlignment"]; }
Unforutnately, when the underlying data table (the _dtHoldings object) changes - all of the NTreeListColumns lose the properties I set above (width/visible/contentAlign). Here is the code that updates the data table:
dgHoldings.SuspendLayout();
foreach (DataRow drv in _dtHoldings.Rows) { if (drv["Symbol"].ToString() == newEventArgs.Tick.SymbolName) drv["CurrentPrice"] = newEventArgs.Tick.LastPrice.ToString(_nonCurrencyPrice); }
dgHoldings.ResumeLayout();
What am I doing wrong? How can I change the data in the data table and have it reflected in the NTreeList without losing the property values for width, visible and contentAlign?
Thank you,
Lars
|
Group: Forum Members
Last Active: Last Week
Posts: 3,054,
Visits: 4,009
|
Hi Lars, To do that you need to override NTreeListTableData.PopulateColumns() method as follows: public class MyNTreeListData : NTreeListTableData { protected override void PopulateColumns() { int count = Table.Columns.Count; DataColumn dataColumn; NTreeListColumn listColumn; for (int i = 0; i < count; i++) { dataColumn = Table.Columns[i]; listColumn = new NTreeListColumn(); listColumn.InitFromDataColumn(dataColumn); listColumn.ContentAlign = (ContentAlignment)dataColumn.ExtendedProperties["contentAlignment"]; listColumn.Width = int.Parse(dataColumn.ExtendedProperties["width"].ToString()); listColumn.Visible = bool.Parse(dataColumn.ExtendedProperties["isVisible"].ToString()); Owner.Columns.Add(listColumn); } } }I hope it helps.
Best Regards, Nevron Support Team
|
Group: Forum Members
Last Active: 13 Years Ago
Posts: 22,
Visits: 1
|
Thank you guys for the code. I have implemented it and have found a new error. Here are the details:
It appears to happen sporadically. There is no consistent set of circumstances that I can find that creates the error. Sometimes, all of the columns and the data appear to be scrunched over to the left (all stacked on top of each other) just for a moment - and then the columns and data appear to correctly reposition themselves in a big flicker. I have even wrapped all of the code within the PopulateColumns() override method within a try/catch but still get the following error.
Any ideas?
Message -> "Object reference not set to an instance of an object." Source -> "Nevron.Presentation" Target Site -> "{Void PaintGrid(Nevron.UI.WinForm.Controls.NTreeListPaintContext)}"
Stack Trace -> at Nevron.UI.WinForm.Controls.NTreeListNode.PaintGrid(NTreeListPaintContext context) at Nevron.UI.WinForm.Controls.NTreeListNode.PostPaint(NLightUIPaintContext context) at Nevron.UI.WinForm.Controls.NItemsControl.PostPaintChild(NLightUIItem item, NLightUIPaintContext context) at Nevron.UI.WinForm.Controls.NTreeViewEx.l1I1II11I1(NTreeNodeCollection collection, NLightUIPaintContext context, Boolean l1II11Il1I) at Nevron.UI.WinForm.Controls.NTreeViewEx.PrePaint(NLightUIPaintContext context) at Nevron.UI.WinForm.Controls.NItemsControl.OnPaint(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at Nevron.UI.WinForm.Controls.NItemsControl.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.RunDialog(Form form) at System.Windows.Forms.Form.ShowDialog(IWin32Window owner) at WinUI.MDIParent.menuTools_DevTeamArea_Click(Object sender, CommandEventArgs e) in C:\\Projects\\JarvisTrader\\DevTrunk\\WinUI\\MDIParent.cs:line 978 at Nevron.UI.WinForm.Controls.NCommand.OnClick() at Nevron.UI.WinForm.Controls.NCommand.PerformClick() at Nevron.UI.WinForm.Controls.NMenuWindow.OnMouseUp(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at Nevron.UI.WinForm.Controls.NCommandParent.WndProc(Message& m) at Nevron.UI.WinForm.Controls.NMenuWindow.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at Nevron.Interop.Win32.NUser32.DispatchMessage(MSG& msg) at Nevron.UI.WinForm.Controls.lI11llI1.BeginMessageLoop(Boolean bSubclassForm)
|
Group: Forum Members
Last Active: 13 Years Ago
Posts: 22,
Visits: 1
|
Hi guys. Do you have any further information this error? I have my project manager asking about a solution. Thank you!
|
Group: Forum Members
Last Active: Last Week
Posts: 3,054,
Visits: 4,009
|
Hi Lars, Sorry, that we didn't respond to your problem. We are trying to reproduce the exception that you described but without success. I would like to ask you a couple of questions that might help us to identify the problem: Is this problem appears after you override PopulateColumns? Could you send us the settings of the NTreeList control and what data you are trying to bind? Thanks and sorry for the inconvenience.
Best Regards, Nevron Support Team
|