Telerik Forums
UI for WinForms Forum
1 answer
144 views
Hello,

I need to have the background of the drop down portion of my combobox have alternating colors. I can accomplish this with an event handler for the ItemDataBound event and a simple counter like this:

private void radComboBox1_ItemDataBound(object sender, Telerik.WinControls.UI.ItemDataBoundEventArgs e) 
i++; 
 
FillPrimitive fpOneDropDownItem = (e.DataBoundItem.Children[0] as FillPrimitive); 
fpOneDropDownItem.BackColor = (i % 2 == 0) ? ColorTranslator.FromHtml("#000000") : ColorTranslator.FromHtml("#262626"); 
fpOneDropDownItem.NumberOfColors = 1
 

I would like to get this behavior using a theme. Is it possible? I see there is an IsOdd property on the grid, is there something similar for the combobox?

Thanks,

-Gary
Nikolay
Telerik team
 answered on 27 Nov 2008
1 answer
370 views
I'm using the following straight from the help file to load a textboxelement to a RadMenu of:
(VS2008 VB.NET)

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
 Dim textItem As New RadMenuContentItem()
 Dim textBox As New RadTextBoxElement()
 textBox.Text = "Enter text here"
 textBox.MinSize = New Size(100, 0)
 textItem.ContentElement = textBox
 textItem.ContentElement.AutoSizeMode = RadAutoSizeMode.WrapAroundChildren
 radMenu1.Items.Add(textItem)
 Dim buttonItem As New RadMenuContentItem()
 Dim button As New RadButtonElement()
 button.Text = "OK"
 AddHandler button.Click, AddressOf button_Click
 buttonItem.ContentElement = button
 radMenu1.Items.Add(buttonItem)
End Sub
Sub button_Click(ByVal sender As Object, ByVal e As EventArgs)
 Dim contentItem As RadMenuContentItem = TryCast(radMenu1.Items(0), RadMenuContentItem)
 Dim textBox As RadTextBoxElement = TryCast(contentItem.ContentElement, RadTextBoxElement)
 MessageBox.Show("Text is: " + textBox.Text)
End Sub

However I get the following error:
at radMenu1.Items.Add(textItem)

What do I need to do differently?
Thanks


System.NullReferenceException was unhandled
  Message="Object reference not set to an instance of an object."
  Source="Telerik.WinControls.UI"
  StackTrace:
       at Telerik.WinControls.UI.RadMenuContentItem.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.Layout.WrapLayoutPanel.arrangeLine(Single v, Single lineV, Int32 start, Int32 end, Boolean useItemU, Single itemU)
       at Telerik.WinControls.Layout.WrapLayoutPanel.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.RadElement.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.RootRadElement.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RootRadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
       at Telerik.WinControls.RadElement.UpdateLayout()
       at Telerik.WinControls.ComponentLayoutElementTree.GetPreferredSize(Size sizeConstraints)
       at Telerik.WinControls.RadControl.GetPreferredSize(Size proposedSize)
       at System.Windows.Forms.Layout.DefaultLayout.xGetDockedSize(IArrangedElement element, Size remainingSize, Size constraints, Boolean measureOnly)
       at System.Windows.Forms.Layout.DefaultLayout.GetVerticalDockedSize(IArrangedElement element, Size remainingSize, Boolean measureOnly)
       at System.Windows.Forms.Layout.DefaultLayout.LayoutDockedControls(IArrangedElement container, Boolean measureOnly)
       at System.Windows.Forms.Layout.DefaultLayout.xLayout(IArrangedElement container, Boolean measureOnly, Size& preferredSize)
       at System.Windows.Forms.Layout.DefaultLayout.LayoutCore(IArrangedElement container, LayoutEventArgs args)
       at System.Windows.Forms.Layout.LayoutEngine.Layout(Object container, LayoutEventArgs layoutEventArgs)
       at System.Windows.Forms.Control.OnLayout(LayoutEventArgs levent)
       at System.Windows.Forms.ScrollableControl.OnLayout(LayoutEventArgs levent)
       at System.Windows.Forms.ContainerControl.OnLayout(LayoutEventArgs e)
       at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
       at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty)
       at System.Windows.Forms.Layout.LayoutTransaction.DoLayout(IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, String property)
       at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
       at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty)
       at System.Windows.Forms.Layout.LayoutTransaction.DoLayout(IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, String property)
       at System.Windows.Forms.Control.ControlCollection.Add(Control value)
       at Telerik.WinControls.RadControl.RegisterHostedControl(RadHostItem hostElement)
       at Telerik.WinControls.RadHostItem.PerformRoutedEventAction(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadHostItem.OnTunnelEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.UI.RadTextBoxItem.OnTunnelEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.RaiseTunnelEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.RaiseTunnelEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.RaiseTunnelEvent(RadElement sender, RoutedEventArgs args)
       at Telerik.WinControls.RadElement.SetParent(RadElement parent)
       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.RadItemOwnerCollection.OnInsertComplete(Int32 index, Object value)
       at System.Collections.CollectionBase.System.Collections.IList.Add(Object value)
       at Telerik.WinControls.RadItemCollection.Add(RadItem value)
       at Biosketch_2.PubMedGrid.PubMedGrid_Load(Object sender, EventArgs e) in C:\vs2008\Biosketch_2\Biosketch_2\PubMedGrid.vb:line 1729
       at System.Windows.Forms.UserControl.OnLoad(EventArgs e)
       at System.Windows.Forms.UserControl.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.ControlCollection.Add(Control value)
       at Biosketch_2.MainForm.MainForm_Load(Object sender, EventArgs e) in C:\vs2008\Biosketch_2\Biosketch_2\MainForm.vb:line 77
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at Telerik.WinControls.RadFormBase.WndProc(Message& msg)
       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.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       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 Biosketch_2.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:
Nikolay
Telerik team
 answered on 26 Nov 2008
5 answers
162 views
I'm trying to make two columns, one with a date and one with a time. I would use the DateTimeColumn, except there doesn't seem to be a very good way to format it as time. Also, the DateTimeColumn doesn't apply formatting to filter cells (or to its own cells for that matter - you have to modify them in the CellFormatting event.)

My solution was to just use MaskBoxColumns with masks that would correspond to date and time, respectively. However, MaskBoxColumns don't apply whatever value you assign to the Mask property, for whatever reason. It seems to always want to format anything entered as a monetary value, regardless of the mask. The MaskType value is also unavailable in this context.

My next step was to attempt to make a regular column and insert the MaskBoxeElements as necessary in the CellFormatting event, as described here: http://www.telerik.com/community/forums/thread/b311D-hhddm.aspx

This causes an exception in the "key" paramater of something - the stack trace was very vague and I couldn't pinpoint the problem, nor could I reproduce it when stepping through code - it only affected runtime.

So my question boils down to whichever of the following is easiest to answer:
1) Can I format a DateTimeColumn to be time? (e.g. 11:23 AM) If so, how do I apply DateTimeColumn formatting to a filter cell for that row?
2) Can I apply masks to MaskBoxColumns and have them actually affect the input?
3) Can I insert MaskBox controls into a column without causing fatal runtime errors?

Help is greatly appreciated, once I get this ironed out I don't forsee any other problems with my project; everything else is fairly straightforward.


Boyko Markov
Telerik team
 answered on 26 Nov 2008
1 answer
104 views
When I use System.Windows.Form as Telerik.WinControls.RadForm on Windows 2003 title bar is not shown (everything works fine on Windows XP). When I use other than Office2007Blue or ControlDefault styles (for example Desert) it's shown when I point mouse cursor over one of control box buttons, but it disappears again when window's state is changing (maximizing, minimizing and recover etc.). The solution is to use RadRibbonForm with RadTitleBar on it, but using RadForm is much easier.
Nick
Telerik team
 answered on 26 Nov 2008
1 answer
104 views
Hi can anyone help with this issue with gridview.

I have a gridview and the first column has been convert to the mutlicolumn dropdown. Then when i add a new row the gridview i want transfer the data from that row in the multicolumngridview dropdown to the gridview.

Hope someone can help, i am vb.net

Cheers

T
Martin Vasilev
Telerik team
 answered on 25 Nov 2008
1 answer
106 views
I have a Radmenu that I use to switch between different views on my spreadsheet control.

My click event will call a method to flip the active sheet on my spreadsheet control and then set the focus to that control.

The odd thing is that if I physically click the menu item, the focus will move to my spreadsheet control and then immediately go back to the menu item. But if I use the keyboard and press "space" on the menu item, the focus will remain on the spreadsheet control (as expected).

I tested this with a sample app that has a radmenu with 2 items, and two buttons. Each menu item will set the focus to a button. Each button has a Enter and Leave event that updates the text of the button.  The behaviour I'm noticing is replicated in this project.

    public partial class Form1 : Form  
    {  
        public Form1()  
        {  
            InitializeComponent();  
        }  
 
        private void button1_Enter(object sender, EventArgs e)  
        {  
            button1.Text = "got focus";  
        }  
 
        private void button1_Leave(object sender, EventArgs e)  
        {  
            button1.Text = "lost focus";  
        }  
 
        private void radMenuItem1_Click(object sender, EventArgs e)  
        {  
            button1.Focus();  
        }  
 
        private void radMenuItem2_Click(object sender, EventArgs e)  
        {  
            button2.Focus();  
        }  
 
        private void button2_Enter(object sender, EventArgs e)  
        {  
            button2.Text = "got focus";  
        }  
 
        private void button2_Leave(object sender, EventArgs e)  
        {  
            button2.Text = "lost focus";  
        }  
    } 
Jack
Telerik team
 answered on 25 Nov 2008
1 answer
135 views
Hi, I just don't know where to start, so I turn to you.

I need to bind a grid to hierarchical data. Which goes to three nested levels deep. On every level I need to summarize the totals of the childtables. It more like a tree view of the dataset including totals for rows.

So on the highest level I would see the totals of all childtables.

My guess would be that I add a custom row at the end of each childtable in the view which would hold the totals of the childtables.

I should also be possible to export this grid to Excell. would that be a problem, concerning the custom added total rows?

Hope you can point me in the right direction.

Thanks

Martin Vasilev
Telerik team
 answered on 25 Nov 2008
1 answer
127 views
I am using a ComboBoxColumn in my grid, and also allowing filtering on that column.  My ComboBoxColumn uses the DisplayMember and ValueMember settings to show the correct text in the cells, which all works very well.  

However, when the user sets a filter on the column, such as "Equal to", they are able to select a value from a dropdownlist, which is great, but after selecting a value, the filter display reverts to the numeric value of their choice, instead of using the DisplayName property to display the corresponding text.  Is there a way to display the DisplayName value in the filter cell?

Thanks,
Rachel
Martin Vasilev
Telerik team
 answered on 25 Nov 2008
3 answers
177 views
Hi,

I need to use this mask '##0.#'
So if I launch my application it will display '___._'. That's correct.

The problem is when I change the Value.

By default : (on debug)
  this.RadMaskedEditBox_Test.Mask "##0.#" string
  this.RadMaskedEditBox_Test.Value "" object {string}
  this.RadMaskedEditBox_Test.Text "___._" string

Value to set :
  Singleton.Instance.MarketGrowthRate 1.4 decimal

 


this
.RadMaskedEditBox_Test.Value = Singleton.Instance.MarketGrowthRate.ToString(this.RadMaskedEditBox_Test.Mask);  
 

 

 

 


After this code :
  this.RadMaskedEditBox_Test.Value "14" object {string}
  this.RadMaskedEditBox_Test.Text "14_._" string
It doesn't set 1.4 in the value and "__1.4" in the text.

And I can't use something like n1 because I must have a maxlength. (999.9)

Thanks for your help



 

Boyko Markov
Telerik team
 answered on 24 Nov 2008
1 answer
141 views
Hi,
I wanted to add a dataset which has three tables that are independant (i.e. do not have any relations). I use the following code to do this but it does not work.  What do i need to do?  I expect it to show me three plus signs one for each table in the same grid but it does not it only shows the "Report" table.
thanks,
Bahram Moinvaziri

 

// radGridViewFCDetails  from the designer

 

 

this.radGridViewFCDetails.AllowShowFocusCues = true;
this.radGridViewFCDetails.AutoGenerateHierarchy = true;
this.radGridViewFCDetails.AutoGenerateHierarchyFromDataSet = true;
this.radGridViewFCDetails.AutoSizeRows = true;
this.radGridViewFCDetails.Dock = System.Windows.Forms.DockStyle.Fill;
this.radGridViewFCDetails.EnableAlternatingRowColor = true;
this.radGridViewFCDetails.EnableHotTracking = false;
this.radGridViewFCDetails.Location = new System.Drawing.Point(3, 17);
this.radGridViewFCDetails.Margin = new System.Windows.Forms.Padding(0);
this.radGridViewFCDetails.Name = "radGridViewFCDetails";
this.radGridViewFCDetails.ShowGroupPanel = false;
this.radGridViewFCDetails.Size = new System.Drawing.Size(702, 205);
this.radGridViewFCDetails.TabIndex = 64;

 

// these lines are in another function
radGridViewFCDetails.EnableHotTracking = false;
radGridViewFCDetails.MasterGridViewTemplate.EnableGrouping = true;
radGridViewFCDetails.MasterGridViewTemplate.AllowAddNewRow = false;
radGridViewFCDetails.MasterGridViewTemplate.AllowEditRow = false;
radGridViewFCDetails.MasterGridViewTemplate.AllowDeleteRow = false;
radGridViewFCDetails.MasterGridViewTemplate.EnableFiltering = false;
radGridViewFCDetails.MasterGridViewTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
radGridViewFCDetails.AutoGenerateHierarchy = true;
radGridViewFCDetails.GridElement.BeginUpdate();
GridViewTemplate template1 = new GridViewTemplate();
template1.DataSource = fcResultsData.Tables["Summary"];
 

radGridViewFCDetails.MasterGridViewTemplate.ChildGridViewTemplates.Add(template1);
GridViewTemplate template2 = new GridViewTemplate();
template2.DataSource = fcResultsData.Tables["Error"];
radGridViewFCDetails.MasterGridViewTemplate.ChildGridViewTemplates.Add(template2);
radGridViewFCDetails.DataSource = fcResultsData.Tables["Report"];
radGridViewFCDetails.GridElement.EndUpdate(true);

Nick
Telerik team
 answered on 24 Nov 2008
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?