Telerik Forums
UI for WinForms Forum
44 answers
2.9K+ views
Hi
I'm using Linq to bind data to a binddatasource which in trun feeds data to a radgridiview.  It works fine when I first bind data to the radgridview.  But if I changed the search criteria and thus the Linq statement, the radgrdiview throws the following exception.

Before I upgrade to 2009Q1 SP1, I need to

                tblitemItemsBindingSource.DataSource = null;  // throw exception if without this statement using 2008Q3
                tblitemItemsBindingSource.DataSource = qItems.OrderBy(i => i.item_Code).ToList();

However, after upgraded to 2009Q1 SP1, the above line is no longer useful.

In my experience, 2009Q1 breaks more things more than it fixes.  I'm very flustrated.

Edwin 

 System.NullReferenceException was unhandled
  Message="Object reference not set to an instance of an object."
  Source="Telerik.WinControls.GridView"
  StackTrace:
       at Telerik.WinControls.UI.BaseGridNavigator.get_CurrentGroup()
       at Telerik.WinControls.UI.BaseGridNavigator.SelectRow(GridViewRowInfo row)
       at Telerik.WinControls.UI.GridTableElement.UpdateCurrentPosition()
       at Telerik.WinControls.UI.GridViewInfo.SetCurrentRow(GridViewRowInfo row, Boolean setPosition, Boolean shift, Boolean control, Boolean rightMouseButton)
       at Telerik.WinControls.UI.GridViewTemplate.SetCurrentRow(GridViewRowInfo rowInfo)
       at Telerik.WinControls.Data.DataAccessComponent.InitDataGrid()
       at Telerik.WinControls.Data.DataAccessComponent.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
       at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
       at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
       at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
       at System.Windows.Forms.BindingSource.ResetBindings(Boolean metadataChanged)
       at System.Windows.Forms.BindingSource.SetList(IList list, Boolean metaDataChanged, Boolean applySortAndFilter)
       at System.Windows.Forms.BindingSource.ResetList()
       at System.Windows.Forms.BindingSource.set_DataSource(Object value)
       at PopularIT.MOSES.POS.UI.frmSearchItem.fillGrid(Boolean expandRows) in C:\Projects\MOSES.POS\MOSES.POS\UI\frmSearchItem.cs:line 85
       at PopularIT.MOSES.POS.UI.frmSearchItem.txtItemName_KeyDown(Object sender, KeyEventArgs e) in C:\Projects\MOSES.POS\MOSES.POS\UI\frmSearchItem.cs:line 146
       at System.Windows.Forms.Control.OnKeyDown(KeyEventArgs e)
       at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
       at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
       at System.Windows.Forms.Control.WmKeyChar(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
       at System.Windows.Forms.TextBox.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 System.Windows.Forms.Form.ShowDialog()
       at PopularIT.MOSES.POS.UI.frmSales.btnSearch_Click(Object sender, EventArgs e) in C:\Projects\MOSES.POS\MOSES.POS\UI\frmSales.cs:line 266
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.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 System.Windows.Forms.Form.ShowDialog()
       at PopularIT.MOSES.POS.UI.frmMain.btnSales_Click(Object sender, EventArgs e) in C:\Projects\MOSES.POS\MOSES.POS\UI\frmMain.cs:line 121
       at PopularIT.MOSES.POS.UI.frmMain.btnSalesNow_Click(Object sender, EventArgs e) in C:\Projects\MOSES.POS\MOSES.POS\UI\frmMain.cs:line 170
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.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.Run(Form mainForm)
       at PopularIT.MOSES.POS.Program.Main() in C:\Projects\MOSES.POS\MOSES.POS\Program.cs:line 82
       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:
Dimitar
Telerik team
 answered on 10 Oct 2017
1 answer
78 views

Hello,

I have a Radgrid.

What i want to do is, that when a numeric value is negative it should be in forecolor red. This is not the Problem.

But when i group the grid by any of the header other values have forecolor red although the value is not negative and its fieldname is not "erfolg"  or "erfolgprozent".

 

My code is:

 

 If TypeOf e.CellElement.ColumnInfo Is GridViewDataColumn Then
            If DirectCast(e.CellElement.ColumnInfo, GridViewDataColumn).FieldName.ToLower = "erfolg" Or DirectCast(e.CellElement.ColumnInfo, GridViewDataColumn).FieldName.ToLower = "erfolgprozent" Then
                If IsNumeric(e.CellElement.Value) Then
                    If CDbl(e.CellElement.Value) < 0 Then
                        e.CellElement.ForeColor = System.Drawing.Color.Red
                    Else
                        e.CellElement.ForeColor = System.Drawing.Color.Black
                    End If
                End If
            End If
        End If

 

Manuel
Top achievements
Rank 1
 answered on 10 Oct 2017
2 answers
279 views

Hello,

Is there a way to have RadDataEntry controls read only? I know I can set Enabled =False for the whole RadDataEntry control but i"d like to limit it for some users while allow others to make changes. Also, users with read only access should be able to copy RadDataEntry controls values which is not the case for Enabled=False scenario.

Any clue is appreciated.

Thanks

Wojciech

Dimitar
Telerik team
 answered on 09 Oct 2017
1 answer
201 views

Hello, 

how can I change the "GridViewPdfExport.PageSize Property" from Default 210 x 297 mm to Din A 4 Landscape 297 x 210 mm?

Namespace "Telerik.WinControls.Export" is imported.

Using PdftoExport is not an option because I need the header feature. 

I am using VB.Net.

Thanks in advance,

F. Schulze

Dimitar
Telerik team
 answered on 09 Oct 2017
4 answers
323 views

hi ,

I want my binding data source to update or refresh after adding a new record to the database.When I add one it won't update till closing and re-opening the form.

Sina
Top achievements
Rank 1
 answered on 07 Oct 2017
1 answer
164 views

I would like the Ribbonbar to always appear collapsed even when I select some of the tabs on it.  I want to be able to expand it only when certian criteria are met.

So far I have been unable to get the ribbonbar to start off Collapsed, nor can I get it to remain collapsed.

 

Please Advise

 

Thanks

 

Jason

Dimitar
Telerik team
 answered on 06 Oct 2017
4 answers
160 views

I have a RadSplitbutton with 6 subitems.    When I click on the arrow, I expect the dropdown menu to be displayed, instead it is first firing the click event of the button, then displaying the menu.  This is not what I wan to happen!

How to I prevent this from happening when trying to select the Arrow?

 

Thanks

 

Jason

 

 

Dimitar
Telerik team
 answered on 06 Oct 2017
1 answer
199 views

Grid is cleared and then Loaded with data. User selects "new row" and the system puts them on a specific cell. User enters a value and TABS or ENTERS. Then does other tasks. User returns to the grid which is again cleared and then Loaded with data. The user selects "new row" and the system puts them on a specific cell, which is prepopulated with the previous value entered. 

>>> Would like not to have the new row cell pre-populated 

 

Steps:

1. Add a value to a cell (a) on a new grid row and commit it.

2. Perform other tasks on the form

3. Return to the Grid in (1) and open a new row. 

> The value from (1) is set as the default for the cell (a)

Although I clear the grid before repopulating, I haven't been able to remove this default (previous) value. 

 

Just before I Load the grid:  

dgvItems.Rows.Clear()

 

 

Any ideas how to prevent it from pre-populating? 

 

 

 

 

 

 

 

 

 

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 06 Oct 2017
1 answer
103 views

Hi,

I'm working on a project where I need to display data in Telerik RadGridView.

One of the column is going to display icons (can be multiple, displayed horizontally). These icons will be provided from .resx file of the project.

I was exploring custom column, tried creating custom column with RadPanelElement assuming that I'll be able to add picturebox windows control to the RadPanelElement object like

protected override void SetContentCore(object value)
        {
            if (this.Value != null && this.Value != DBNull.Value)
            {
                //this.radProgressBarElement.Value1 = Convert.ToInt16(this.Value);
                //this.radImageList
                foreach(string strImgIndex in this.Value.ToString().Split(','))
                {
                    PictureBox pbIcon = new PictureBox();
                    switch (int.Parse(strImgIndex))
                    {
                        case 0:
                            pbIcon.Image = WindowsFormsApplication1.Properties.Resources.binoculars;
                            break;

                        case 1:
                            pbIcon.Image = WindowsFormsApplication1.Properties.Resources.open;
                            break;

                        case 2:
                            pbIcon.Image = WindowsFormsApplication1.Properties.Resources.printer;
                            break;
                    }

                    //this.radImageList.Controls.Add (NOT ABLE TO ADD CONTROLS DYNAMICALLY)
                    //pbIcon.Image = Image.
                }
            }

It didn't work as not able to add controls to RadPanelElement. Please provide a way out to achieve the required custom column.

Thanks & Regards

Brajendra Singh

 

Lance | Senior Manager Technical Support
Telerik team
 answered on 05 Oct 2017
5 answers
446 views

Hello,

I have a grid view with a cell containing either a TextBox which is ReanOnly or a ComboBox for which the user has to select a value.

The arrow button of ComboBox cell is only visible when user clicks on cell to edit it. Thus, the user does not know if he has to select or not a value

I'd like that the arrow button of ComboBox cell is always visible to indicate to user that a value has to be selected.

I've tried to set the visibility of arrow button in EditorRequired event but it has no effect.

        void QualityControlsEntryGridView_EditorRequired(object sender, EditorRequiredEventArgs e)
        {
            if (QualityControlsEntryGridView.Columns["Result"].IsCurrent)
            {
                if (QualityControlsEntryGridView.CurrentRow.Cells["ReferenceValueToType"].Value.ToString() != "")
                {
                    e.Editor = new RadTextBoxEditor();
                    e.EditorType = typeof(RadTextBoxEditor);
                }
                else
                {
                    e.Editor = new RadDropDownListEditor();
                    e.EditorType = typeof(RadDropDownListEditor);
                    RadDropDownListEditorElement editorElement = (RadDropDownListEditorElement)((RadDropDownListEditor)e.Editor).EditorElement;
                    editorElement.ArrowButton.Visibility = ElementVisibility.Visible;
                }
            }
        }

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 05 Oct 2017
Narrow your results
Selected tags
Tags
GridView
General Discussions
Scheduler and Reminder
Treeview
Dock
RibbonBar
Themes and Visual Style Builder
ChartView
Calendar, DateTimePicker, TimePicker and Clock
DropDownList
Buttons, RadioButton, CheckBox, etc
ListView
ComboBox and ListBox (obsolete as of Q2 2010)
Chart (obsolete as of Q1 2013)
Form
PageView
MultiColumn ComboBox
TextBox
RichTextEditor
PropertyGrid
Menu
RichTextBox (obsolete as of Q3 2014 SP1)
Panelbar (obsolete as of Q2 2010)
PivotGrid and PivotFieldList
Tabstrip (obsolete as of Q2 2010)
MaskedEditBox
CommandBar
PdfViewer and PdfViewerNavigator
ListControl
Carousel
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
Toolstrip (obsolete as of Q3 2010)
VirtualGrid
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
Documentation
SplitContainer
Map
DesktopAlert
CheckedDropDownList
ProgressBar
TrackBar
MessageBox
Rotator
SpinEditor
CheckedListBox
StatusStrip
LayoutControl
SyntaxEditor
Wizard
ShapedForm
TextBoxControl
Conversational UI, Chat
DateTimePicker
CollapsiblePanel
TabbedForm
CAB Enabling Kit
GroupBox
WaitingBar
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
ColorDialog
FileDialogs
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
Styling
Barcode
BindingNavigator
PopupEditor
RibbonForm
TaskBoard
Callout
ColorBox
PictureBox
FilterView
NavigationView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
ButtonTextBox
FontDropDownList
BarcodeView
BreadCrumb
Security
LocalizationProvider
Dictionary
Overlay
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
SplashScreen
ToolbarForm
NotifyIcon
DateOnlyPicker
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?