Telerik Forums
UI for WinForms Forum
3 answers
306 views
Hello,
I am attempting to add an image button to each row in the grid.  I have found a couple of old posts that detailed exactly what I am trying to do.  However, when I tried to implement the code I am getting an "Out of Memory" error.  The image that I am trying to load is only 2 KB, and the exception occurs on the first row in the gird, so I wouldn't think this would be an issue.  I can successfully load the image to a Picturebox control on the form without a problem.

In the Form_Load event, I call this method to load the image:

Private Sub LoadAppImages()  
        Dim myAssembly As System.Reflection.Assembly 
        Dim myNamespace As String 
        Dim fileName As String 
 
        myAssembly = System.Reflection.Assembly.GetEntryAssembly  
        myNamespace = myAssembly.GetName.Name  
 
        
        fileName = myNamespace & ".tool_dropdown.png" 
 
        Using stream As System.IO.Stream = myAssembly.GetManifestResourceStream(fileName)  
 
            If stream IsNot Nothing Then 
                _toolsIcon = Image.FromStream(stream)  
            End If 
 
            stream.Close()  
 
        End Using  
 
    End Sub 

Then in the CellFormatting event, I configure the image button:

Private Sub rgLines_CellFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles rgLines.CellFormatting  
          
        If TypeOf (e.CellElement.ColumnInfo) Is GridViewDataColumn AndAlso _  
            Not TypeOf (e.CellElement.RowElement) Is GridTableHeaderRowElement Then 
 
            Dim column As GridViewDataColumn = CType(e.CellElement.ColumnInfo, GridViewDataColumn)  
 
            If column.FieldName = "TOOLS" Then 
 
                'Check to see if the button has already been added   
                If e.CellElement.Children.Count > 0 Then 
 
                    Exit Sub 
 
                End If 
 
                Dim toolsButton As New RadImageButtonElement  
 
                toolsButton.DisplayStyle = DisplayStyle.Image  
                toolsButton.Image = _toolsIcon  
 
                e.CellElement.Children.Add(toolsButton)  
                ApplyThemeToElement(toolsButton, "ControlDefault")  
 
            End If 
 
        End If 
 
    End Sub 

The error occurs when I call "e.CellElement.Children.Add(toolsButton)". 

Here is the full Stack Trace.  Any ideas what I may be doing wrong?

System.Reflection.TargetInvocationException was unhandled
  Message="Exception has been thrown by the target of an invocation."
  Source="mscorlib"
  StackTrace:
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle 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.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
       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.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
       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(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(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at WinFormQuotesGrid.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       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.OutOfMemoryException
       Message="Out of memory."
       Source="System.Drawing"
       StackTrace:
            at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
            at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
            at System.Drawing.Bitmap.MakeTransparent(Color transparentColor)
            at Telerik.WinControls.Primitives.ImagePrimitive.get_Image()
            at Telerik.WinControls.Primitives.ImagePrimitive.OnPropertyChanged(RadPropertyChangedEventArgs e)
            at Telerik.WinControls.RadObject.UpdateEffectiveValue(RadProperty dp, RadPropertyMetadata metadata, Boolean isCoerceValue, Boolean isOldValueValid, Object oldValue, ValueSource oldValueSource, Boolean oldValueIsDeferred, Boolean coerceWithDeferredReference)
            at Telerik.WinControls.RadObject.SetValueCommon(RadProperty dp, Object value, RadPropertyMetadata metadata, Boolean coerceWithDeferredReference)
            at Telerik.WinControls.RadObject.SetValue(RadProperty dp, Object value)
            at Telerik.WinControls.RadObject.BindProperty(RadProperty myProperty, RadObject bindingSourceObject, RadProperty bindingSourceProperty, PropertyBindingOptions propertyBindingOptions)
            at Telerik.WinControls.UI.RadButtonElement.CreateChildElements()
            at Telerik.WinControls.RadElement.EnsureChildElements()
            at Telerik.WinControls.RadElement.InvalidateTotalTransformationReqursively()
            at Telerik.WinControls.RadElement.InvalidateTransformations(Boolean invalidateElement)
            at Telerik.WinControls.RadElement.ChangeCollection(RadElement child, ItemsChangeOperation changeOperation)
            at Telerik.WinControls.RadElementCollection.OnInsertComplete(Int32 index, Object value)
            at System.Collections.CollectionBase.System.Collections.IList.Insert(Int32 index, Object value)
            at Telerik.WinControls.RadElementCollection.Insert(Int32 index, RadElement value)
            at WinFormQuotesGrid.Form1.rgLines_CellFormatting(Object sender, CellFormattingEventArgs e) in C:\projects\ProjectQuote\WinFormQuotesGrid\WinFormQuotesGrid\Form1.vb:line 166
            at Telerik.WinControls.UI.RadGridView.OnCellFormatting(Object sender, CellFormattingEventArgs e)
            at Telerik.WinControls.UI.RadGridView.CallCellFormatting(Object sender, CellFormattingEventArgs e)
            at Telerik.WinControls.UI.GridDataRowElement.UpdateInfo()
            at Telerik.WinControls.UI.GridRowElement.Initialize(GridViewRowInfo rowInfo)
            at Telerik.WinControls.UI.GridTableBodyElement.UpdateRow(Int32 position, GridViewRowInfo rowInfo)
            at Telerik.WinControls.UI.GridTableBodyElement.UpdateRowElements(IEnumerable`1 rows, RectangleF clientRect, Single& y, Int32& position, Int32 startIndex, Int32& added, Single left, Single width)
            at Telerik.WinControls.UI.GridTableBodyElement.ArrangeOverride(SizeF finalSize)
            at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
            at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
            at Telerik.WinControls.UI.GridTableElement.ArrangeOverride(SizeF finalSize)
            at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
            at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
            at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
            at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayoutCallback(ILayoutManager manager)
       InnerException:


Victor
Telerik team
 answered on 17 Jun 2009
7 answers
1.6K+ views
Hi.
I have a Rad button with an image.
I want to set 'hover' image and 'click' image.

What is the best way to do so?
Martin Vasilev
Telerik team
 answered on 17 Jun 2009
1 answer
127 views

When I call

window.DockManager.ActiveWindow = window;

this activates the DocumentWindow in the Manager, but it paints itself correctly only if the tab of the DocumentWindow was already visible on the TabStrip.

If the tab is not visible (too many open documents), I get an empty window with no contents.

If I activate the window through the drop-down menu, it is inserted to the beginning of the TabStrip and thus shown
correctly.

regards
Erwin

 

 

 

 

Julian Benkov
Telerik team
 answered on 17 Jun 2009
6 answers
156 views

What's the best way to convert UserDockForm derived Dockables to the new DocumentWindow?

Do I have to convert them to Controls and then add them to the DocumentWindow.Controls Collection?

regards
Erwin
Julian Benkov
Telerik team
 answered on 17 Jun 2009
1 answer
94 views
Hi,

I am developing a web application with telerik controls. I am using the radGrid in the application. I am facing a weird  problem with new version of Telerik.Web.UI.dll. The version which I am using is 2009.1.527.20.

Problem Description:
When the grid width is 50% of the screen width then the paging controls (like Page size and Change button ) are displaying out side grid control. It was not happening with the telerik version 2008.3.........

Please provide the solution.

Thanks
Hari

Pavlina
Telerik team
 answered on 17 Jun 2009
3 answers
560 views
According to the documentation RadMenu is supposed to support accelerator keys (Alt+F for example).

From the documentation (RadMenu -> Usability -> Keyboard Navigation):
  • After opening a menu use the arrow keys to move the selection up and down the menu, or to move sideways from menu to menu.
  • If the menu is equipped with accelerator keys, you can press Alt plus the key to activate a menu item. Accelerator keys are indicated by an underlined letter. For example, if you see the menu text New Item, then N is the accelerator key and Alt+N will activate the menu item.
  • If the menu displays a shortcut (such as Ctrl+N) to the right of the menu item text, pressing the shortcut key combination will activate the menu item.

But I can't seem to get this to work.  Am I missing something?

Thanks,
Eric


Boryana
Telerik team
 answered on 16 Jun 2009
7 answers
237 views
hi,
I m using version "RadControls for WinForms Q1 2008 SP1", but I did not found any template c:\program files\telerik\RadControls for WinForms Q1 2008 SP1\templates
so please guide me how can I use RadForm in Visual Studio 2008.
What steps are required to use RadFormControl.

Regards
Deyan
Telerik team
 answered on 16 Jun 2009
11 answers
505 views
I've just found out that many telerik WinForms controls (Ribbon, Menu, etc) do not support OpenType fonts which are essential for the text of many Unicode languages to render properly. Indian, Arabic and many other Asian languages depend entirely on OpenType to render. In fact, most fonts found in Windows today are in OpenType format.

Note that OpenType is natively supported in Win 2000, XP and Vista, in all .NET controls, many third-party controls, and WPF as well. I find it odd that telerik WinForms doesn't support it.

Resources to read if you don't know OpenType:
http://msdn2.microsoft.com/en-us/library/ms745109.aspx
http://www.microsoft.com/typography/otspec/TTOCHAP1.htm
http://en.wikipedia.org/wiki/OpenType
Peter
Telerik team
 answered on 16 Jun 2009
1 answer
163 views
I have an unbound radgridview that I populate from a .CSV file.

I used AddCheckboxColumn() code I found in this forum to add a 'Select All' header checkbox.

I have two issues.

I want to enable and disable a button on the form based on 'all checkboxes cleared' = disabled and 'all checkboxes selected' = enabled

I can do this by adding ...

            If valueState = False And frmClientsImport.btnAddToDB.Enabled = True Then
                frmClientsImport.btnAddToDB.Enabled = False
            ElseIf valueState = True And frmClientsImport.btnAddToDB.Enabled = False And Not frmClientsImport.cboCustomers Is Nothing Then
                frmClientsImport.btnAddToDB.Enabled = True
            End If

...to Private Sub checkbox_ToggleStateChanged(ByVal sender As Object, ByVal args As StateChangedEventArgs)

but this is obviously not the way to do it because then I've kind of locked the subroutine to the specific radgridview.

Second, if an individual checkbox is selected/deselected I want to enable the same button as long as at least one row has a checkbox checked and disable the button if no rows have the checkbox checked. I tried the .ValueChanged event but it doesn't seem to report the state correctly.
Nikolay
Telerik team
 answered on 15 Jun 2009
1 answer
140 views
Hi,

I am trying to remove the bottom "footer" that appears in calendar pop up when I want to select a date using datetimepicker.

This footer is purple, it´s driving me crazy because I have no idea how to make it not show.

Do you know what property I have to change to make it no visible?

Thank you in advance.
 
Martin Vasilev
Telerik team
 answered on 15 Jun 2009
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)
Form
Chart (obsolete as of Q1 2013)
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
PdfViewer and PdfViewerNavigator
CommandBar
ListControl
Carousel
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
VirtualGrid
Toolstrip (obsolete as of Q3 2010)
Label
AutoCompleteBox
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
SplitContainer
Documentation
Map
DesktopAlert
CheckedDropDownList
ProgressBar
MessageBox
TrackBar
Rotator
SpinEditor
CheckedListBox
StatusStrip
SyntaxEditor
Wizard
CollapsiblePanel
LayoutControl
ShapedForm
TextBoxControl
Conversational UI, Chat
DateTimePicker
TabbedForm
CAB Enabling Kit
WaitingBar
GroupBox
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
FileDialogs
ColorDialog
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
NavigationView
BindingNavigator
RibbonForm
Styling
Barcode
PopupEditor
TaskBoard
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
BreadCrumb
ButtonTextBox
FontDropDownList
BarcodeView
Overlay
Security
LocalizationProvider
Dictionary
TreeMap
StepProgressBar
SplashScreen
Flyout
Separator
SparkLine
ToolbarForm
NotifyIcon
DateOnlyPicker
AI Coding Assistant
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
SpeechToTextButton
SmartPasteButton
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?