Telerik Forums
UI for WinForms Forum
2 answers
168 views
I have a collection of custom visual items contained in a RadListView.  These visual items consist of several RadTextBoxElements and a RadDropDownListElement.  If a new item is added to the RadListView, say the drop down list item selected is different than the one above it, then the user scrolls up, the selected item of the drop down list for the next to last item becomes the selected item of the new item's drop down.  Doing this again propagates it up the visual items.

I have debugged all code and determined that there are some inconsistencies in scrolling that seem to be making this happen.  I can get around it if the scrollbar does not start at the bottom by setting focus to the first textbox in the visual item.  This scrolls to the bottom and then I cannot reproduce.  

What is happening here?  Any ideas?

Below are my overridden CreateChileElements and SynchronizeProperties methods:

base.CreateChildElements();
 
//Setup the name label and field in a stack panel layout
this.nameStackPanelElement = new StackLayoutElement();
this.nameStackPanelElement.Orientation = Orientation.Horizontal;
this.nameStackPanelElement.ElementSpacing = 17;
this.nameStackPanelElement.StretchHorizontally = true;
this.nameLabelElement = new RadLabelElement();
this.nameLabelElement.Text = "Name";
this.nameLabelElement.AutoSize = true;
this.nameLabelElement.StretchHorizontally = false;
this.nameTextBoxElement = new RadTextBoxElement();
this.nameTextBoxElement.StretchHorizontally = true;
this.nameTextBoxElement.MinSize = new Size(120, 0);
this.nameTextBoxElement.TextBoxItem.MaxLength = 100;
this.nameTextBoxElement.TextBoxItem.LostFocus += new EventHandler(NameTextBoxItem_LostFocus);
this.nameTextBoxElement.TextChanged += new EventHandler(ImportantField_TextChanged);
this.nameStackPanelElement.Children.Add(this.nameLabelElement);
this.nameStackPanelElement.Children.Add(this.nameTextBoxElement);
 
//Setup the script label and field in a stack panel layout
this.scriptStackPanelElement = new StackLayoutElement();
this.scriptStackPanelElement.Orientation = Orientation.Horizontal;
this.scriptStackPanelElement.ElementSpacing = 18;
this.scriptStackPanelElement.StretchHorizontally = true;
this.scriptLabelElement = new RadLabelElement();
this.scriptLabelElement.Text = "Script";
this.scriptLabelElement.AutoSize = true;
this.scriptLabelElement.StretchHorizontally = false;
this.scriptTextBoxElement = new RadTextBoxElement();
this.scriptTextBoxElement.StretchHorizontally = true;
this.scriptTextBoxElement.MinSize = new Size(120, 0);
this.scriptTextBoxElement.TextBoxItem.MaxLength = 30;
this.scriptTextBoxElement.TextBoxItem.LostFocus += new EventHandler(ScriptTextBoxItem_LostFocus);
this.scriptTextBoxElement.TextChanged += new EventHandler(ImportantField_TextChanged);
this.scriptStackPanelElement.Children.Add(this.scriptLabelElement);
this.scriptStackPanelElement.Children.Add(this.scriptTextBoxElement);
 
//Setup the modifier label and drop down list in a stack panel layout
this.modifierStackPanelElement = new StackLayoutElement();
this.modifierStackPanelElement.Orientation = Orientation.Horizontal;
this.modifierStackPanelElement.ElementSpacing = 4;
this.modifierStackPanelElement.StretchHorizontally = true;
this.modifierLabelElement = new RadLabelElement();
this.modifierLabelElement.Text = "Modifier";
this.modifierLabelElement.AutoSize = true;
this.modifierLabelElement.StretchHorizontally = false;
this.modifierDropDownListElement = new RadDropDownListElement();
this.modifierDropDownListElement.StretchHorizontally = true;
this.modifierDropDownListElement.MinSize = new Size(60, 0);
this.modifierDropDownListElement.DropDownStyle = RadDropDownStyle.DropDownList;
this.modifierDropDownListElement.SelectedIndexChanged +=
    new Telerik.WinControls.UI.Data.PositionChangedEventHandler(modifierDropDownListElement_SelectedIndexChanged);
this.modifierStackPanelElement.Children.Add(this.modifierLabelElement);
this.modifierStackPanelElement.Children.Add(this.modifierDropDownListElement);
 
//Fill the modifier drop down list and select the zeroth element
foreach (ModKeys mod in Enum.GetValues(typeof(ModKeys)))
{
    this.modifierDropDownListElement.Items.Add(mod.ToString());
}
 
//Setup the key label and field in a stack panel layout
this.keyStackPanelElement = new StackLayoutElement();
this.keyStackPanelElement.Orientation = Orientation.Horizontal;
this.keyStackPanelElement.ElementSpacing = 4;
this.keyLabelElement = new RadLabelElement();
this.keyLabelElement.Text = "Key";
this.keyLabelElement.AutoSize = true;
this.keyLabelElement.StretchHorizontally = false;
this.keyTextBoxElement = new RadTextBoxElement();
this.keyTextBoxElement.StretchHorizontally = true;
this.keyTextBoxElement.MinSize = new Size(34, 0);
this.keyTextBoxElement.TextBoxItem.MaxLength = 1;
this.keyTextBoxElement.TextBoxItem.LostFocus += new EventHandler(KeyTextBoxItem_LostFocus);
this.keyTextBoxElement.TextChanged += new EventHandler(ImportantField_TextChanged);
this.keyStackPanelElement.Children.Add(this.keyLabelElement);
this.keyStackPanelElement.Children.Add(this.keyTextBoxElement);
 
//Combine the key and modifier panels into one stack panel layout
this.modifierKeyStackPanelElement = new StackLayoutElement();
this.modifierKeyStackPanelElement.Orientation = Orientation.Horizontal;
this.modifierKeyStackPanelElement.ElementSpacing = 4;
this.modifierKeyStackPanelElement.StretchHorizontally = true;
this.modifierKeyStackPanelElement.Children.Add(this.modifierStackPanelElement);
this.modifierKeyStackPanelElement.Children.Add(this.keyStackPanelElement);
 
//Setup the save and cancel buttons in a stack panel layout
this.newButtonsStackPanelElement = new StackLayoutElement();
this.newButtonsStackPanelElement.Orientation = Orientation.Horizontal;
this.newButtonsStackPanelElement.ElementSpacing = 4;
this.newButtonsStackPanelElement.StretchHorizontally = true;
Padding newButtonsStackMargin = this.newButtonsStackPanelElement.Margin;
this.newButtonsStackPanelElement.Margin = new Padding(52, newButtonsStackMargin.Top,
    -12, newButtonsStackMargin.Bottom);
this.saveButtonElement = new RadButtonElement("Save");
this.saveButtonElement.Enabled = false;
this.saveButtonElement.Click += new EventHandler(saveButtonElement_Click);
this.cancelButtonElement = new RadButtonElement("Cancel");
this.cancelButtonElement.Click += new EventHandler(deleteCancelButtonElement_Click);
this.newButtonsStackPanelElement.Children.Add(this.saveButtonElement);
this.newButtonsStackPanelElement.Children.Add(this.cancelButtonElement);
 
//Setup the insert and delete buttons in a stack panel layout and set them
//to collapsed initially.
this.existingButtonsStackPanelElement = new StackLayoutElement();
this.existingButtonsStackPanelElement.Orientation = Orientation.Horizontal;
this.existingButtonsStackPanelElement.Visibility = ElementVisibility.Collapsed;
this.existingButtonsStackPanelElement.ElementSpacing = 4;
this.existingButtonsStackPanelElement.StretchHorizontally = true;
Padding existingButtonsStackMargin = this.existingButtonsStackPanelElement.Margin;
this.existingButtonsStackPanelElement.Margin = new Padding(52, existingButtonsStackMargin.Top - 4,
    -12, existingButtonsStackMargin.Bottom + 4);
this.insertButtonElement = new RadButtonElement("Insert");
this.insertButtonElement.Click += new EventHandler(insertButtonElement_Click);
this.deleteButtonElement = new RadButtonElement("Delete");
this.deleteButtonElement.Click += new EventHandler(deleteCancelButtonElement_Click);
this.existingButtonsStackPanelElement.Children.Add(this.insertButtonElement);
this.existingButtonsStackPanelElement.Children.Add(this.deleteButtonElement);
 
//Setup the separator that will separate this item from the one below it
this.itemSeparator = new SeparatorElement();
this.itemSeparator.StretchHorizontally = true;
this.itemSeparator.Line1.BackColor = Color.FromArgb(76, 76, 76);
//Padding separatorMargin = itemSeparator.Margin;
//this.itemSeparator.Margin = new Padding(separatorMargin.Left, separatorMargin.Top + 4, separatorMargin.Right, separatorMargin.Bottom);
 
//Setup the outermost stack panel layout element and add all
//of the other stack panel layout elements as its children.
this.parentStackPanelElement = new StackLayoutElement();
this.parentStackPanelElement.Orientation = Orientation.Vertical;
this.parentStackPanelElement.ElementSpacing = 4;
this.parentStackPanelElement.Margin = new Padding(4);
this.parentStackPanelElement.StretchHorizontally = true;
this.parentStackPanelElement.Children.Add(this.nameStackPanelElement);
this.parentStackPanelElement.Children.Add(this.scriptStackPanelElement);
this.parentStackPanelElement.Children.Add(this.modifierKeyStackPanelElement);
this.parentStackPanelElement.Children.Add(this.newButtonsStackPanelElement);
this.parentStackPanelElement.Children.Add(this.existingButtonsStackPanelElement);
this.parentStackPanelElement.Children.Add(this.itemSeparator);
 
//Finally, add the outermost stack panel layout element to the
//SimpleListViewVisualItem's Children
this.Children.Add(this.parentStackPanelElement);


lock (Program.scriptsLockObject)
            {
                base.SynchronizeProperties();
 
                this.Text = "";
 
                this.Script = this.Data.Value as Script;
 
                if (this.Script != null)
                {
                    if (this.Script.IsNew)
                    {
                        this.newButtonsStackPanelElement.Visibility = ElementVisibility.Visible;
                        this.existingButtonsStackPanelElement.Visibility = ElementVisibility.Collapsed;
 
                        //if (!this.IsElementVisible)
                        //{
 
                        //}
 
                        this.nameTextBoxElement.Focus();
                    }
                    else
                    {
                        this.newButtonsStackPanelElement.Visibility = ElementVisibility.Collapsed;
                        this.existingButtonsStackPanelElement.Visibility = ElementVisibility.Visible;
 
                        this.insertButtonElement.Enabled = !string.IsNullOrWhiteSpace(this.Script.ScriptText);
                    }
 
                    this.nameTextBoxElement.Text = this.Script.Name;
                    this.scriptTextBoxElement.Text = this.Script.ScriptText;
                    this.modifierDropDownListElement.SelectedIndex = (int)this.Script.KeyModifier;
                    this.keyTextBoxElement.Text = this.Script.Key;
                }
            }
Adam
Top achievements
Rank 1
 answered on 16 Mar 2012
2 answers
175 views
Hello,

during the development of a WinForms application for our customer the following problem arose when using multiple summary rows in grid:

1) the attached picture shows existing grid with 2 summary rows. The requirement is that first summary row sums data only from even rows and the second summary row sums data only from odd rows. Is it possible to achieve these "filtered" sums? The grid is bound with custom objects which contain a boolean value which would serve as a basis for addition of data (DataBoundItem).

2) how can custom style be applied to specific summary row when using multiple summary rows (in our scenario the first summary row should be blue and the second one red)?
Tomaz
Top achievements
Rank 1
 answered on 16 Mar 2012
2 answers
188 views
Hi,

Is it possible to configure RadGridView to have different child templates on the same level of hierarchical data rows? Or to have different columns collections for each group?

I want to accomplish something like this:

[Data model]
Class Flat
{
 string name; 
 List<Room> rooms;
}

Class Room
{
 string name;
 bool table;
 bool bath;
 bool desk;
 int walls;
}

[View]

1. Expandable rows with objects  "Flat" (visible columns: Name)
2. Second hierarchy with rooms, but on this level different columns visible for every room type:

If room name is "Bathroom" then columns are: name, bath, walls.
If room name is "Saloon" then columns are: name, table, walls.
etc.

Is it feasible on one grid?

Best Regards
 Krzysztof

Jack
Telerik team
 answered on 16 Mar 2012
4 answers
225 views
Is it possible to format a column using number formats or date formats?

Thanks,

Javier Gonzalez de Aragon
Ivan Todorov
Telerik team
 answered on 16 Mar 2012
3 answers
250 views
I understand you can perform custom sorting using a grid and a tree but how do you do this from within a RadListView?  Basically I have a bound column that contains strings, some are words, some are numbers.  I need to sort them in a "unique" manner.  Can I pass a column a custom sort method or hook a sort event or pass a custom sort descriptor or ???
Ivan Todorov
Telerik team
 answered on 16 Mar 2012
3 answers
141 views
Hello,

I was wondering if anyone has any experience reloading a HostWindow.  I can get the HostWindows I need from my DockWindows, gather the info I need from it, close the the HostWindow, make my new calculations, create a new HostWindow and add it to the Dock.  However, this just puts the new HostWindow on the most recent document that had focus.  What I want is for the new HostWindow to show up/refresh in the same spot.  Does anyone know if this is possible?  

This is what I was thinking; but it leaves the old HostWindow in the Dock and does not seem to add the "new" HostWindow to the dock.
//set the current window to a host window, if not a host window will return null
HostWindow hw = this.dockMain.DockWindows[i] as HostWindow;
 
//creates new form in hostwindow
hw = new HostWindow(createRightForm(tempModel, formName));

If you need anymore info from me just let me know.  Thanks.  
Julian Benkov
Telerik team
 answered on 16 Mar 2012
5 answers
632 views
How do i get scroll bars to appear on a radribbonform.
I have a simple project with a radribbon form and a rad panel
I have set autoscroll to true but the scroll bars do not appear as the form is resized
Ivan Todorov
Telerik team
 answered on 16 Mar 2012
1 answer
150 views
Is there a way to write this in winforms. I got this example from silverlight docs.
Private Function CreateChart_DefaultView() As Telerik.Windows.Controls.RadChart
    Dim telerikChart As New Telerik.Windows.Controls.RadChart()
    'Chart Title
    telerikChart.DefaultView.ChartTitle.Content = "Year 2009"
    telerikChart.DefaultView.ChartTitle.HorizontalAlignment = HorizontalAlignment.Center
    'Chart Legend
    telerikChart.DefaultView.ChartLegend.UseAutoGeneratedItems = True
    'Line Chart
    Dim lineSeries As New DataSeries()
    lineSeries.LegendLabel = "Turnover"
    lineSeries.Definition = New LineSeriesDefinition()
    Dim dataPoint As New DataPoint()
    dataPoint.YValue = 154
    dataPoint.XCategory = "Jan"
    lineSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 138
    dataPoint.XCategory = "Feb"
    lineSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 143
    dataPoint.XCategory = "Mar"
    lineSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 120
    dataPoint.XCategory = "Apr"
    lineSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 135
    dataPoint.XCategory = "May"
    lineSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 125
    dataPoint.XCategory = "Jun"
    lineSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 179
    dataPoint.XCategory = "Jul"
    lineSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 170
    dataPoint.XCategory = "Aug"
    lineSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 198
    dataPoint.XCategory = "Sep"
    lineSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 187
    dataPoint.XCategory = "Sep"
    lineSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 193
    dataPoint.XCategory = "Nov"
    lineSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 176
    dataPoint.XCategory = "Dec"
    lineSeries.Add(dataPoint)
    telerikChart.DefaultView.ChartArea.DataSeries.Add(lineSeries)
    'Bar Chart
    Dim barSeries As New DataSeries()
    barSeries.LegendLabel = "Expenses"
    barSeries.Definition = New BarSeriesDefinition()
    dataPoint = New DataPoint()
    dataPoint.YValue = 45
    dataPoint.XCategory = "Jan"
    barSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 48
    dataPoint.XCategory = "Feb"
    barSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 53
    dataPoint.XCategory = "Mar"
    barSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 41
    dataPoint.XCategory = "Apr"
    barSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 32
    dataPoint.XCategory = "May"
    barSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 28
    dataPoint.XCategory = "Jun"
    barSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 63
    dataPoint.XCategory = "Jul"
    barSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 74
    dataPoint.XCategory = "Aug"
    barSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 77
    dataPoint.XCategory = "Sep"
    barSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 85
    dataPoint.XCategory = "Oct"
    barSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 89
    dataPoint.XCategory = "Nov"
    barSeries.Add(dataPoint)
    dataPoint = New DataPoint()
    dataPoint.YValue = 80
    dataPoint.XCategory = "Dec"
    barSeries.Add(dataPoint)
    telerikChart.DefaultView.ChartArea.DataSeries.Add(barSeries)
    Return telerikChart
End Function
I am well versed on using winforms chart control. I would like to do the same using RadChart. A few examples would be nice. Thank you.

G
Evgenia
Telerik team
 answered on 16 Mar 2012
1 answer
139 views
Hi

I need to "drag and drop" columns from a gridview to another control; for example a simple text box that just prints the header name when the column is droped on to it. 

I have mined the posts here and the WinFroms demo, all implementing on the drag and drop service:
  RadDragDropService dragDropService = this.radGridView1.GridViewElement.GetService<RadDragDropService>();
            dragDropService.PreviewDragOver += new System.EventHandler<RadDragOverEventArgs>(dragDropService_PreviewDragOver);
            dragDropService.PreviewDragDrop += new System.EventHandler<RadDropEventArgs>(dragDropService_PreviewDragDrop);

 However, it seems that PreviewDragOver  and PreviewDragDrop  events are fired only when hitting on the listed members here:
http://www.telerik.com/help/winforms/t_telerik_wincontrols_ui_listcontroldragdropservice.html 

and not a textbox or other generic container.

My question is: is there anyway i can allow and detect a column drop using some other code OR implement a new control that will implement the radservice

Thanks in advance.
Jack
Telerik team
 answered on 16 Mar 2012
8 answers
327 views
I am using a licensed version of 2011.Q2 so it's not the latest but it's all that I have for the time being.

I set a filter callback for a ComboBoxColumn in the CellEditorInitialized event handler like this:

 

RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
if (editor != null)
{
    RadDropDownListEditorElement editorElement = (RadDropDownListEditorElement)editor.EditorElement;
    editorElement.Filter = FilterWrappers;
}

 

This works fine. The problem is that I have another ComboBoxColumn with no filter on it. When I click in the first column and select a value and then click in the second column the filter method for the first column is called. It is called once for every item in the combo but the entries contain items from the first combo and items from the second combo. Why is this happening?

Julian Benkov
Telerik team
 answered on 15 Mar 2012
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
Diagram, DiagramRibbonBar, DiagramToolBox
GanttView
Panorama
New Product Suggestions
Toolstrip (obsolete as of Q3 2010)
VirtualGrid
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
Documentation
SplitContainer
Map
DesktopAlert
ProgressBar
CheckedDropDownList
TrackBar
MessageBox
Rotator
SpinEditor
StatusStrip
CheckedListBox
LayoutControl
SyntaxEditor
Wizard
ShapedForm
TextBoxControl
Conversational UI, Chat
DateTimePicker
CollapsiblePanel
TabbedForm
CAB Enabling Kit
GroupBox
DataEntry
ScrollablePanel
ScrollBar
WaitingBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
ColorDialog
FileDialogs
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
BindingNavigator
PopupEditor
RibbonForm
Styling
TaskBoard
Barcode
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
NavigationView
DataLayout
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
ButtonTextBox
FontDropDownList
Licensing
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
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?