Hello! I have following code:
this.systemPointsGridView.MasterTemplate.DataSource
=
this.systemTableBindingSource;
...
this.systemTableBindingSource.DataMember
=
"SystemTable";
this.systemTableBindingSource.DataSource
=
this.projectDataSet;
...
projectDataSet is filling somewhere
and then
in order the results to be displayed
I have to write:
systemTableBindingSource.DataSource = projectDataSet;
So, the question is why do I have to reassign dataset to BindingSource
datasource property? I suppose that it should be done automatically, or
there should be method that I must call on binding source in order to
populate control with data.
It seems that I missed something in databinding mechanism...
Thanks in advance.
listBox1.Items.Add(message);
if (listBox1.Items.Count > 100)
{
listBox1.Items.RemoveAt(0);
}
listBox1.SelectedIndex = listBox1.Items.Count - 1;
listBox1.ClearSelected();
I want to use RadListControl because it can handle html syntax.
Please suggest something on this. I can even switch to another control which supports html code.
regards,
Bibek Dawadi
Private Sub txtBuscar_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBuscar.TextChanged wFirstVisibleRow = -1 Me.gridArticulos.MasterTemplate.Refresh() If wFirstVisibleRow > 0 Then Dim wposcode As String = gridArticulos.MasterTemplate.Rows(wFirstVisibleRow).Cells(0).Value.ToString If wposcode <> "" Then Me.ArticulosSGFBindingSource.Position = Me.ArticulosSGFBindingSource.Find("CODIGO", wposcode) End If End If End Sub Private Sub gridArticulos_CustomFiltering(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCustomFilteringEventArgs) Handles gridArticulos.CustomFiltering If String.IsNullOrEmpty(Me.txtBuscar.Text) Then e.Visible = True For i As Integer = 0 To Me.gridArticulos.ColumnCount - 1 e.Row.Cells(i).Style.Reset() e.Row.InvalidateRow() Next Return End If e.Visible = False For i As Integer = 0 To Me.gridArticulos.ColumnCount - 1 If i <> 2 Then Dim text As String = e.Row.Cells(i).Value.ToString() If text.IndexOf(Me.txtBuscar.Text, 0, StringComparison.InvariantCultureIgnoreCase) >= 0 Then e.Visible = True If wFirstVisibleRow = -1 Then wFirstVisibleRow = e.Row.Index End If e.Row.Cells(i).Style.CustomizeFill = True e.Row.Cells(i).Style.DrawFill = True e.Row.Cells(i).Style.BackColor = Color.FromArgb(201, 252, 254) Else e.Row.Cells(i).Style.Reset() e.Row.InvalidateRow() End If End If Next End SubFor Each row As DataRow In ds_sn.Tables("sn_tbl_groups").Rows Dim tag As New radmenuitem(row(1).ToString) tag.CheckOnClick = New EventHandler(AddressOf GroupMenuclick) Me.btn_SpecificGroup.Items.Add(tag) NextHello,
I use:
I try to evaluate RadGridView but with simple file explorer (hierarchy, self reference, unbound mode, load on demand/expansion) and I get exceptions.
I isolate problems
to simple file explorer. Cound You help me to solve these problems ?
1. Add rows in begin/end section after expanded event.
Is it necessary to add rows in statements begin/end ?
If I do it, I get exception
System.NullReferenceException was unhandled Message=Object reference not set to an instance of an object. Source=Telerik.WinControls StackTrace: at Telerik.WinControls.RadObject.RaisePropertyNotifications(RadPropertyValue propVal, Object oldValue, Object newValue, ValueSource oldSource) at Telerik.WinControls.RadObject.SetValueCore(RadPropertyValue propVal, Object propModifier, Object newValue, ValueSource source) at Telerik.WinControls.RadElement.SetValueCore(RadPropertyValue propVal, Object propModifier, Object newValue, ValueSource source) at Telerik.WinControls.RadObject.OnTwoWayBoundPropertyChanged(PropertyBinding binding, Object newValue) at Telerik.WinControls.PropertyBinding.UpdateSourceProperty(Object newValue) at Telerik.WinControls.RadPropertyValue.SetLocalValue(Object value) at Telerik.WinControls.RadObject.SetValueCore(RadPropertyValue propVal, Object propModifier, Object newValue, ValueSource source) at Telerik.WinControls.RadElement.SetValueCore(RadPropertyValue propVal, Object propModifier, Object newValue, ValueSource source) at Telerik.WinControls.UI.GridExpanderItem.set_Expanded(Boolean value) at Telerik.WinControls.UI.GridExpanderItem.OnMouseUp(MouseEventArgs e) at Telerik.WinControls.RadElement.OnCLREventsRise(RoutedEventArgs args) at Telerik.WinControls.RadElement.OnBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadItem.OnBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e) at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e) at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e) at Telerik.WinControls.UI.RadGridView.OnMouseUp(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at Telerik.WinControls.RadControl.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(IntPtr 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.Run(Form mainForm) at TelerikRadControlsWinFormsPrototype.Program.Main() in D:\rdawidziuk\src\OSS 12.2\Support\Prototypes\Technology\Presentation\TelerikRadControlsWinFormsPrototype\Program.cs:line 19 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: i get exception. It takes some time, but after minutes I always get this exception:
System.NullReferenceException was unhandled Message=Object reference not set to an instance of an object. Source=Telerik.WinControls.GridView StackTrace: at Telerik.WinControls.UI.GridTraverser.StepInHierarchyBackward() at Telerik.WinControls.UI.GridTraverser.MovePreviousCore() at Telerik.WinControls.UI.GridTraverser.MovePrevious() at Telerik.WinControls.UI.BaseGridNavigator.MoveToNextRow(Int32 step, Boolean moveNextDirection) at Telerik.WinControls.UI.BaseGridNavigator.SelectPreviousColumn() at Telerik.WinControls.UI.GridRowBehavior.ProcessLeftKey(KeyEventArgs keys) at Telerik.WinControls.UI.GridRowBehavior.ProcessKey(KeyEventArgs keys) at Telerik.WinControls.UI.BaseGridBehavior.ProcessKey(KeyEventArgs keys) at Telerik.WinControls.UI.BaseGridBehavior.ProcessKeyDown(KeyEventArgs keys) at Telerik.WinControls.UI.RadGridView.OnKeyDown(KeyEventArgs e) at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m) at System.Windows.Forms.Control.ProcessKeyMessage(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at Telerik.WinControls.RadControl.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(IntPtr 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.Run(Form mainForm) at TelerikRadControlsWinFormsPrototype.Program.Main() in D:\rdawidziuk\src\OSS 12.2\Support\Prototypes\Technology\Presentation\TelerikRadControlsWinFormsPrototype\Program.cs:line 19 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: using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;using Telerik.WinControls;using Telerik.WinControls.UI;using System.IO;namespace TelerikRadControlsWinFormsPrototype{ public partial class MyFileSystemExplorer : Telerik.WinControls.UI.RadForm { private int idCounter = 0; public MyFileSystemExplorer() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // grid initialize this.radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting); this.radGridView1.ChildViewExpanded += new ChildViewExpandedEventHandler(radGridView1_ChildViewExpanded); this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "ID", "ParentID"); this.radGridView1.ImageList = this.imageList1; this.radGridView1.TableElement.RowHeight = 35; // colums GridViewDataColumn idCol = new GridViewDecimalColumn(); idCol.DataType = typeof(int); idCol.Name = "ID"; idCol.ReadOnly = true; idCol.IsVisible = false; this.radGridView1.Columns.Add(idCol); GridViewDataColumn parentIdCol = new GridViewDecimalColumn(); parentIdCol.DataType = typeof(int); parentIdCol.Name = "ParentID"; parentIdCol.ReadOnly = true; parentIdCol.IsVisible = false; this.radGridView1.Columns.Add(parentIdCol); GridViewDataColumn nameCol = new GridViewTextBoxColumn(); nameCol.DataType = typeof(string); nameCol.Name = "Name"; nameCol.HeaderText = "Name"; nameCol.ReadOnly = true; this.radGridView1.Columns.Add(nameCol); GridViewDataColumn modiffCol = new GridViewTextBoxColumn(); modiffCol.DataType = typeof(DateTime); modiffCol.Name = "Creation"; modiffCol.HeaderText = "Creation"; modiffCol.ReadOnly = true; this.radGridView1.Columns.Add(modiffCol); // root rows List<FileSystemInfoWrp> drivesInfo = new List<FileSystemInfoWrp>(); foreach (DriveInfo di in DriveInfo.GetDrives()) { drivesInfo.Add(new FileSystemInfoWrp(this.idCounter++, di.RootDirectory)); } this.Add(null, drivesInfo.ToArray()); } void radGridView1_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e) { if (e.IsExpanded) { FileSystemInfoWrp parent = (FileSystemInfoWrp)e.ParentRow.Tag; // adding in begin/end update section invokes NullReferenceException, why ? //this.radGridView1.BeginUpdate(); try { this.Add(parent, this.GetFileSystemElements(parent)); } finally { //this.radGridView1.EndUpdate(); } this.radGridView1.GridNavigator.SelectRow(e.ParentRow); } else { // remove child nodes, always read files from hdd foreach(GridViewRowInfo gvri in e.ParentRow.ChildRows) { this.radGridView1.Rows.Remove(gvri); } } } void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) { GridDataCellElement cell = e.CellElement as GridDataCellElement; if (cell != null && cell.ExpanderItem != null) { cell.ImageAlignment = ContentAlignment.MiddleLeft; cell.ExpanderItem.Alignment = ContentAlignment.MiddleLeft; if (((FileSystemInfoWrp)e.Row.Tag).ElementInfo is DirectoryInfo) { if (e.Row.IsExpanded) { cell.Image = this.imageList1.Images[1]; } else cell.Image = this.imageList1.Images[0]; cell.ExpanderItem.Visibility = ElementVisibility.Visible; } else { cell.Image = this.imageList1.Images[2]; cell.ExpanderItem.Visibility = ElementVisibility.Hidden; } cell.TextImageRelation = TextImageRelation.ImageBeforeText; } } private FileSystemInfoWrp[] GetFileSystemElements(FileSystemInfoWrp root) { List<FileSystemInfoWrp> result = new List<FileSystemInfoWrp>(); if (root.ElementInfo is DirectoryInfo) { try { FileSystemInfo[] infos = ((DirectoryInfo)root.ElementInfo).GetFileSystemInfos(); foreach (FileSystemInfo fi in infos) { result.Add(new FileSystemInfoWrp(this.idCounter++, fi)); } } catch // omits io exception { } } return result.ToArray(); } private void Add(FileSystemInfoWrp parent, FileSystemInfoWrp[] fileInfos) { foreach (FileSystemInfoWrp fsiw in fileInfos) { GridViewRowInfo row = this.radGridView1.Rows.AddNew(); row.Cells["ID"].Value = fsiw.Id; if (parent != null) row.Cells["ParentID"].Value = parent.Id; row.Cells["Name"].Value = fsiw.ElementInfo.Name; row.Cells["Creation"].Value = fsiw.ElementInfo.CreationTime; row.Tag = fsiw; } } } public class FileSystemInfoWrp { public int Id { get; set; } public FileSystemInfo ElementInfo { get; set; } public FileSystemInfoWrp(int id, FileSystemInfo elementInfo) { this.Id = id; this.ElementInfo = elementInfo; } }}using TelerikRadControlsWinFormsPrototype.Properties;namespace TelerikRadControlsWinFormsPrototype{ partial class MyFileSystemExplorer { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MyFileSystemExplorer)); this.radGridView1 = new Telerik.WinControls.UI.RadGridView(); this.imageList1 = new System.Windows.Forms.ImageList(this.components); ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this)).BeginInit(); this.SuspendLayout(); // // radGridView1 // this.radGridView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(248))))); this.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill; this.radGridView1.ForeColor = System.Drawing.Color.Black; this.radGridView1.Location = new System.Drawing.Point(0, 0); // // radGridView1 // this.radGridView1.MasterTemplate.AllowColumnChooser = false; this.radGridView1.MasterTemplate.AutoGenerateColumns = false; this.radGridView1.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.MasterTemplate.Caption = null; this.radGridView1.MasterTemplate.MultiSelect = true; this.radGridView1.MasterTemplate.ShowGroupedColumns = true; this.radGridView1.Name = "radGridView1"; // // // this.radGridView1.RootElement.ForeColor = System.Drawing.Color.Black; this.radGridView1.Size = new System.Drawing.Size(1216, 786); this.radGridView1.TabIndex = 2; this.radGridView1.Text = "radGridView1"; this.radGridView1.ThemeName = "Telerik"; // // imageList1 // this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); this.imageList1.TransparentColor = System.Drawing.Color.Transparent; this.imageList1.Images.SetKeyName(0, "folder_blue_open1.png"); this.imageList1.Images.SetKeyName(1, "folder1.png"); this.imageList1.Images.SetKeyName(2, "new1.png"); // // MyFileSystemExplorer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1216, 786); this.Controls.Add(this.radGridView1); this.Name = "MyFileSystemExplorer"; // // // this.RootElement.ApplyShapeToControl = true; this.Text = "My File System Explorer"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this)).EndInit(); this.ResumeLayout(false); } #endregion private Telerik.WinControls.UI.RadGridView radGridView1; private System.Windows.Forms.ImageList imageList1; }}