Telerik Forums
UI for WinForms Forum
2 answers
164 views
Hi,
I am trying to implement a custom DataGridCellElement that contains a label and a hyperlink. For both elements I use RadLabelElements with different font styles. 
My problem is, that if the cell is too small to hold the whole text of both elements the text of the hyperlink is drawn into the neighboring cell on the right. What is wrong with my code?
(Q1 2011 SP1, .NET 3.5)

Thanks in advance, Christoph
public class HyperlinkCellElement : GridDataCellElement
{
    private RadLabelElement _headerLabel;
    private RadLabelElement _linkLabel;
 
    public HyperlinkCellElement(GridViewColumn column, GridRowElement row) : base(column, row) {}
 
    protected override Type ThemeEffectiveType { get {return typeof(GridDataCellElement); } }
 
    public override void Initialize(GridViewColumn column, GridRowElement row)
    {
        base.Initialize(column, row);
        _headerLabel.Text = column.Name;
    }
 
    protected override void CreateChildElements()
    {
        _headerLabel = new RadLabelElement();
        _headerLabel.Font = new Font(Font, FontStyle.Bold);
        _headerLabel.Margin = new Padding(0, 2, 0, 0);
        _headerLabel.LabelText.AutoEllipsis = true;
        _headerLabel.LabelText.AutoSize = true;
        _headerLabel.LabelText.AutoSizeMode = RadAutoSizeMode.Auto;
        _headerLabel.LabelText.TextWrap = false;
         
        _linkLabel = new RadLabelElement();
        _linkLabel.Font = new Font(Font, FontStyle.Underline);
        _linkLabel.MouseHover += (s, e) =>
             { if (Cursor.Current == Cursors.Default) Cursor.Current = Cursors.Hand; };
        _linkLabel.MouseLeave += (s, e) =>
             { if (Cursor.Current == Cursors.Hand) Cursor.Current = Cursors.Default; };
        _linkLabel.Margin = new Padding(0, 2, 0, 0);
        _linkLabel.LabelText.AutoEllipsis = true;
        _linkLabel.LabelText.AutoSize = true;
        _linkLabel.LabelText.AutoSizeMode = RadAutoSizeMode.Auto;
        _linkLabel.LabelText.TextWrap = false;
 
        this.Children.Add(_headerLabel);
        this.Children.Add(_linkLabel);
 
        _linkLabel.Click += new EventHandler(_label_Click);
    }
 
    void _label_Click(object sender, EventArgs e)
    {
        //TODO;
    }
 
    protected override void DisposeManagedResources()
    {
        _linkLabel.Click -= new EventHandler(_label_Click);
        base.DisposeManagedResources();
    }
 
    protected override void SetContentCore(object value)
    {
        _linkLabel.Text = value.ToString();
    }
 
    protected override SizeF ArrangeOverride(SizeF finalSize)
    {
        if (this.Children.Count == 2)
        {
            var label = this.Children[0];
            var link = this.Children[1];
 
            var labelWidth = Math.Min(finalSize.Width, label.DesiredSize.Width);
            var linkWidth = Math.Min(link.DesiredSize.Width, finalSize.Width - labelWidth);
 
            label.Arrange(new RectangleF(
                0,
                (finalSize.Height / 2) - (label.DesiredSize.Height / 2),
                labelWidth,
                label.DesiredSize.Height));
 
            link.Arrange(new RectangleF(
                label.Size.Width,
                (finalSize.Height / 2) - (link.DesiredSize.Height / 2),
                linkWidth,
                link.DesiredSize.Height));
        }
        return finalSize;
    }
 
    public override bool IsCompatible(GridViewColumn data, object context)
    {
        return data is GridViewHyperlinkColumn && context is GridDataRowElement;
    }
}
Christoph
Top achievements
Rank 1
 answered on 15 Jul 2011
1 answer
142 views
 Hi,

I have got a scheduler control, which scrolls to work hours perfectly well when the view is changed (Day, Week). However, when the "ShowWeekend" check box is toggled, the scroll to work time does not work.

The code:
Private Sub radSchedulerAppointmentsNavigator_ShowWeekendStateChanged(ByVal sender As Object, ByVal args As Telerik.WinControls.UI.StateChangedEventArgs) Handles radSchedulerAppointmentsNavigator.ShowWeekendStateChanged
        
If TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerMonthView) Is Nothing Then
            TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerDayViewBase).RulerWidth = 43
            TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerDayViewBase).DayCount = 1
            TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerDayViewBase).AutoScrollToWorkTime = True
 
            Dim dtStart As DateTime = DateTime.Parse(GetOptionValue("WORKINGHOURS", "Start"))
            Dim tsStart As New TimeSpan(dtStart.Hour, dtStart.Minute, 0)
            Dim dtEnd As DateTime = DateTime.Parse(GetOptionValue("WORKINGHOURS", "End"))
            Dim tsEnd As New TimeSpan(dtEnd.Hour, dtStart.Minute, 0)
            TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerDayViewBase).WorkTime = New TimeInterval(tsStart, tsEnd)
 
            If RadRadioButtonGroup.ToggleState = Enumerations.ToggleState.On Then
                TryCast(Me.radSchedulerAppointments.SchedulerElement.ViewElement, SchedulerDayViewGroupedByResourceElement).ScrollToWorkHours()
            Else
                TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerDayViewBase).RulerWidth = 45
                TryCast(Me.radSchedulerAppointments.SchedulerElement.ViewElement, SchedulerDayViewElement).DataAreaElement.ScrollView.Value = Point.Empty
                TryCast(Me.radSchedulerAppointments.SchedulerElement.ViewElement, SchedulerDayViewElement).DataAreaElement.Table.ScrollToWorkHours()
            End If
        End If
    End Sub

Interestingly, if the scheduler is "Grouped by resources" mode (determined by RadRadioButtonGroup.ToggleState), then the scrolling works as required. If it is in normal mode (where RadRadioButtonGroup.ToggleState <> ToggleState.On), scrolling does not work, and the scheduler view starts at 2 AM. Working hours are being determined by options - and the work time is being specified correctly from options (8 AM to 5 PM).

BTW, what does "AutoScrollToWorkTime" do? I did not have it before, but it doesn't seem to make any difference.

Similar code is being used in ActiveViewChanged event of the scheduler control.

Also, I am working with Telerik WinForms version Q1 2011 (and VS 2010). As far as I remember, the code worked before the controls were upgraded from version Q2 2010 SP1. But I could be wrong.

Regards.
Ivan Todorov
Telerik team
 answered on 14 Jul 2011
3 answers
125 views
hi,

i've read this article and that works very well, but my problem is i mus push enter to create the new value.
In my app, i want the new value in the list if i leave the cell or on the endedit event, something like that.
Can you help me please to do that ?
thanks a lot
Martin Vasilev
Telerik team
 answered on 14 Jul 2011
9 answers
274 views
Hi,

is it possible to print treeview ?
thanks
almir
Julian Benkov
Telerik team
 answered on 14 Jul 2011
1 answer
116 views
   I created a standard (non-Telerik) Windows forms app using VS2010.  After adding a few forms, I used the conversion option under "Telerik/RadControls for WinForms" to add access to the Telerik controls.  This added the WinControls assembly references to the project (visible in Solution Explorer), but did not make the new controls visible in the Toolbox.
   How can I gain access to these controls?  Reopening the project and restarting VS was not effective.  I can use the Telerik controls in a fresh project, update them from within VS, and generally use them quite well in other circumstances.

   Thanks!
Chavdar Dimitrov
Telerik team
 answered on 14 Jul 2011
3 answers
126 views
Hello,

I have a problem with a column filter. Please see the following code:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
  
namespace GridTest1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
  
            List<Data> list = new List<Data>();
            list.Add(new Data() { Value = "A" });
            list.Add(new Data() { Value = "B" });
            list.Add(new Data() { Value = "C" });
            bindingSource1.DataSource = list;
        }
  
        private void btnChangeData_Click(object sender, EventArgs e)
        {
            List<Data> list = new List<Data>();
            list.Add(new Data() { Value = "A" });
            bindingSource1.DataSource = list;
        }
    }
  
    public class Data
    {
        public string Value { get; set; }
    }
}

The grid is bound to the BindingSource. The binding source is bound to a list. Initially a list contains 5 records. When I click the column filter, I see all 5 values there. Then I assign another list (with 3 records only) to the BindingSource's DataSource. The grid presents 3 rows. But when I click the column filter, it shows the previous 5 ones (please see the attached image).

This issue occurs in v.2011.1.11.315 and v.2011.1.11.427.

How should I "refresh" the filter in order to see the actual values only?

Thank you.
Svett
Telerik team
 answered on 14 Jul 2011
1 answer
154 views
Hello,
i want to change color in rows in grid, but i can't get RowsID by id of items in bingingsource.
Any idea ?
Stefan
Telerik team
 answered on 14 Jul 2011
5 answers
575 views
i have an app that has a RadWizard component on a tab.  the wizard deals with device interaction and connectivity.  on certain pages (panels) i need to check for certain states of the device.  dependent on the results of the state checks, i need to disable/enable the back/next/cancel buttons.  what i have set up is to "catch" the panel visibility changed event.  if the panel is visible, i do the checks, and possibly disable the next button - as well as other elements on the panel.  the other elements on the panel are disabled/enabled correctly, but the back/next/cancel buttons are still enabled.  i've stepped thru the debugger and verified that the Next Button is disabled, but it appears that there is a "higher" event that is re-enabling the button.enabled properties.  on some panels, i have actions that are controlled by "action" buttons (move, measure, set, etc.) and they disable/enable the buttons, and this works.

is the VisibilityChanged event the correct one for what i'm trying to do?  if not, how can i achieve this?

is this a bug for the control?

thanks,

pete.
Alexander
Telerik team
 answered on 14 Jul 2011
2 answers
138 views
Hi guys,

I have a unique problem, have no idea if it's caused by any settings in my project, I am using radScheduler on a form of my project which is a part of multi-project solution. I have tested radScheduler on an out of the solution project (a separate isolated project), it's working fine,

but within solution, when I drag and drop a scheduler control on my form, it doesn't initialize like other controls in form's designer

it appears abnormally as

Telerik.WinControls.UI.RadScheduler radScheduler1 = new Telerik.WinControls.UI.RadScheduler();

instead of the above, it should have been initialized as

this.radScheduler1 = new Telerik.WinControls.UI.RadScheduler();

neither it appears in form's class like other controls, for example, I have a Telerik pageview on the same form which appears as

private Telerik.WinControls.UI.RadPageViewPage myPageview;

but radScheduler has not been defined anywhere. Moreover, when I try to correct designer generated code, it changes it back again when I select the control on the form at design time, and neither it appears in intellisense window.

all other Telerik controls are working fine.
Ivan Todorov
Telerik team
 answered on 14 Jul 2011
1 answer
81 views
I'm trying to use "LoadFromXML" on RadChart with the following xml, but the XValue displays as 0, 1, 2... What am I missing?

          <RadChart DefaultType="Bar">
            <Series>
              <ChartSeries Type="Bar" Name="Fluxo de Caixa">
                <Items>
                  <ChartSeriesItem XValue="11/07/2011" YValue="64720.21"/>
                  <ChartSeriesItem XValue="15/07/2011" YValue="1916.23"/>
                  <ChartSeriesItem XValue="15/07/2011" YValue="9760.40"/>
                  <ChartSeriesItem XValue="15/07/2011" YValue="11900.57"/>
                  <ChartSeriesItem XValue="15/07/2011" YValue="14216.00"/>
                  <ChartSeriesItem XValue="20/07/2011" YValue="6006.40"/>
                  <ChartSeriesItem XValue="20/07/2011" YValue="7697.82"/>
                  <ChartSeriesItem XValue="20/07/2011" YValue="10511.20"/>
                  <ChartSeriesItem XValue="20/07/2011" YValue="11262.00"/>
                  <ChartSeriesItem XValue="20/07/2011" YValue="22524.00"/>
                  <ChartSeriesItem XValue="21/07/2011" YValue="7122.81"/>
                  <ChartSeriesItem XValue="25/07/2011" YValue="13327.50"/>
                  <ChartSeriesItem XValue="21/08/2011" YValue="7122.81"/>
                  <ChartSeriesItem XValue="21/09/2011" YValue="7122.81"/>
                  <ChartSeriesItem XValue="21/10/2011" YValue="7122.80"/>
                </Items>
              </ChartSeries>
            </Series>
          </RadChart>

Best regards!
Nikolay
Telerik team
 answered on 14 Jul 2011
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
CommandBar
PdfViewer and PdfViewerNavigator
ListControl
Carousel
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
VirtualGrid
Toolstrip (obsolete as of Q3 2010)
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
CollapsiblePanel
Conversational UI, Chat
DateTimePicker
TabbedForm
CAB Enabling Kit
GroupBox
WaitingBar
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
FileDialogs
ColorDialog
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
BindingNavigator
Styling
Barcode
PopupEditor
RibbonForm
TaskBoard
Callout
NavigationView
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
BreadCrumb
ButtonTextBox
FontDropDownList
BarcodeView
Security
LocalizationProvider
Dictionary
SplashScreen
Overlay
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
ToolbarForm
NotifyIcon
DateOnlyPicker
AI Coding Assistant
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?