Telerik Forums
UI for WinForms Forum
1 answer
130 views
I am looking into replacing our current docking control with the RadDock control. What our current dock control allows us to do is have a fairly simple xml configuration to allow dynamic layouts. We have a bunch of controls that can be dynamically loaded, the customer can control which controls are loaded and the layout (dock position, auto hide, and so on).

Example plugin config
<plugin load="true"
        type="AssemblyName, ClassName"
        path=".">
    <Form>
        <Guid>d3b14ad1-e970-4445-9a27-2cedf211ca3a</Guid>
        <AllowedDock>All</AllowedDock>
        <CurrentDock>Bottom</CurrentDock>
        <CurrentMode>Inner</CurrentMode>
        <IsSelected>true</IsSelected>
        <IsAutoHide>false</IsAutoHide>
        <Width>400</Width>
        <Height>371</Height>
        <ParentGuid>1fbc51f7-f459-425b-884d-91a33602440c</ParentGuid>
        <Name>PTZ</Name>
        <Screen>1</Screen>
    </Form>
</plugin>

This control is a child (controlled by CurrentMode tag) and will be display in the bottom portion of it's parent (controlled by the CurrentDock tag). If the CurrentDock is changed to Fill then it will the same space as it's parent and become a TabControl.

My question is, does the RadDock have the ability to allow me to dynamically build up this layout from a simple configuration? I would like to just add the RadDock control to the form and have it built up from the config file, the customer would also need to be able to change the layout.

This is the code that will load all the controls in the app.config file where plugin load = true. This seems to give me the parent / child tab layout I am looking for, but it seems like it's not the "right" way to do it. For instance, if I want two controls docked Left within the RadDock but tabbed, would it be better to create a ToolWindow and add those two controls to that, or pass in the target control (parent) while calling DockControl?

foreach (SnapInBase plugin in BuildPluginHierarchy(this.plugins))
{
    try
    {
        if (plugin.MetaData.ContainsKey("Form") && plugin.MetaData["Form"] != null)
        {
            XmlNode n = plugin.MetaData["Form"];
 
            plugin.Dock = DockStyle.Fill;
 
            DockPosition position = ParseXmlNode<DockPosition>(n, "DockPosition");
            DockType dockType = ParseXmlNode<DockType>(n, "DockType");
 
            Guid guid = ParseXmlNode<Guid>(n, "Guid");
            int width = ParseXmlNode<Int32>(n, "Width", plugin.Width);
            int height = ParseXmlNode<Int32>(n, "Height", plugin.Height);
            bool isAutoHide = ParseXmlNode<Boolean>(n, "IsAutoHide");
            Guid parentGuid = ParseXmlNode<Guid>(n, "ParentGuid");
            int screen = ParseXmlNode<Int32>(n, "Screen", 1);
 
            if (screen == 1)
            {
                if (parentGuid != Guid.Empty)
                {
                    HostWindow parent;
                    if (this.controlCache.TryGetValue(parentGuid, out parent) == true)
                    {
                        HostWindow window = null;
 
                        window = this.radDock1.DockControl(plugin, parent, position, dockType);
 
                        if (isAutoHide == true)
                        {
                            this.radDock1.AutoHideWindow(window);
                        }
 
                        this.controlCache.Add(guid, window);
                    }
                }
                else
                {
                    var window = this.radDock1.DockControl(plugin, position, dockType);
 
                    if (isAutoHide == true)
                    {
                        this.radDock1.AutoHideWindow(window);
                    }
 
                    this.controlCache.Add(guid, window);
                }
            }
        }
        else
        {
            logger.Error(string.Format("No form metadata for {0}", plugin.Name));
        }
    }
    catch (Exception ex)
    {
        logger.Error(ex);
    }
}

What I am hoping for is to find out is if there is a better way to do what I'm trying to do. I will provide the customer a default layout, and they can change it how they see fit.

Thanks,
Matt
Julian Benkov
Telerik team
 answered on 03 Aug 2011
7 answers
752 views
i have custom controls inside a page view control. the custom control binds data on the load event. the problem is whenever a control is being added to the page view the load event of the control is being fired immediately inside the constructor of the control which holds the page view control. as a result it throws exception when trying to access data.

the following code is the component initialization code which is called from the constructor of the control which holds the page view control

private void InitializeComponent()
        {
            this.rdpvAppCodeFiles = new Telerik.WinControls.UI.RadPageView();
            this.rdpvpBank = new Telerik.WinControls.UI.RadPageViewPage();
            this.ctlManageBank1 = new CRS.Client.App.Documents.CodeFiles.ApplicationCodeFiles.BankDocuments.ctlManageBank();
            ((System.ComponentModel.ISupportInitialize)(this.rdpvAppCodeFiles)).BeginInit();
            this.rdpvAppCodeFiles.SuspendLayout();
            this.rdpvpBank.SuspendLayout();
            this.SuspendLayout();
            //
            // rdpvAppCodeFiles
            //
            this.rdpvAppCodeFiles.Controls.Add(this.rdpvpBank);
            this.rdpvAppCodeFiles.Dock = System.Windows.Forms.DockStyle.Fill;
            this.rdpvAppCodeFiles.Location = new System.Drawing.Point(0, 0);
            this.rdpvAppCodeFiles.Name = "rdpvAppCodeFiles";
            this.rdpvAppCodeFiles.SelectedPage = this.rdpvpBank;
            this.rdpvAppCodeFiles.Size = new System.Drawing.Size(846, 502);
            this.rdpvAppCodeFiles.TabIndex = 1;
            this.rdpvAppCodeFiles.Text = "radPageView1";
            this.rdpvAppCodeFiles.SelectedPageChanged += new System.EventHandler(this.rdpvAppCodeFiles_SelectedPageChanged);
            ((Telerik.WinControls.UI.RadPageViewStripElement)(this.rdpvAppCodeFiles.GetChildAt(0))).StripAlignment = Telerik.WinControls.UI.StripViewAlignment.Right;
            ((Telerik.WinControls.UI.RadPageViewStripElement)(this.rdpvAppCodeFiles.GetChildAt(0))).ItemContentOrientation = Telerik.WinControls.UI.PageViewContentOrientation.Horizontal;
            //
            // rdpvpBank
            //
            this.rdpvpBank.Controls.Add(this.ctlManageBank1);
            this.rdpvpBank.Location = new System.Drawing.Point(10, 10);
            this.rdpvpBank.Name = "rdpvpBank";
            this.rdpvpBank.Size = new System.Drawing.Size(750, 481);
            this.rdpvpBank.Text = "Bank";
            //
            // ctlManageBank1
            //
            this.ctlManageBank1.CurrentMode = CRS.Client.Automation.Documents.ctlDocumentUIBase.OperationMode.None;
            this.ctlManageBank1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.ctlManageBank1.Document = null;
            this.ctlManageBank1.Location = new System.Drawing.Point(0, 0);
            this.ctlManageBank1.Name = "ctlManageBank1";
            this.ctlManageBank1.Size = new System.Drawing.Size(750, 481);
            this.ctlManageBank1.TabIndex = 0;
 
            // ctlApplicationCodeFilesSwitchBoard
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.rdpvAppCodeFiles);
            this.Name = "ctlApplicationCodeFilesSwitchBoard";
            this.Size = new System.Drawing.Size(846, 502);
            ((System.ComponentModel.ISupportInitialize)(this.rdpvAppCodeFiles)).EndInit();
            this.rdpvAppCodeFiles.ResumeLayout(false);
            this.rdpvpBank.ResumeLayout(false);
 
            this.ResumeLayout(false);
 
        }


here ctlManageBank1 is my custom control which loads data on its load event. the load event is being called immediately after the control is added to the page object of page view control (bold line).

if i use a tab control instead of a page view control everything goes fine. the load event fires at the time of showing the control, not inside the constructor.


Julian Benkov
Telerik team
 answered on 03 Aug 2011
1 answer
63 views
is there possible to set the
addnewrowposition =bottom propertie of grid in grid theme

plz help

Stefan
Telerik team
 answered on 03 Aug 2011
1 answer
87 views
Hi, i would like to know, the themes of telerik that i build in visual style builder dont run or apply in windows 64bits ?
Im waiting for your response.
Best Regards,

Daniel
Stefan
Telerik team
 answered on 03 Aug 2011
1 answer
130 views

I had created a new thread relating to a question on WinForms GridView, but this is not accessible anymore/has disappeared.
http://www.telerik.com/community/forums/winforms/gridview/editing-gridviewdatetimecolumn.aspx

It does not appear in the WinForms GridView Forum.
However it does appear when we search the WinForms GridView forum with key word "Editing".
Please see attached screenshot.

Just thought someone would like to know.
And if this thread is retrieved, could it please be answered?

Regards
Sameer.
Nikolay
Telerik team
 answered on 03 Aug 2011
1 answer
540 views
Hello

I am working with a databound RadGridView, I would like to intercept data exceptions errors while editing but also while adding a record. At the moment Im more concerned with adding. While adding if the DataError method is called the ErrorText is set for the row, but instead of staying focused in the current cell, it deletes all data in all cells that were entered. There is an exclamation icon set in the first column of the grid when the ErrorText is set but it is overlapping the current icon.

Isnt the e.Cancel = true line supposed to cancel validation and keep the focus in the current cell till valid data is entered?

private void radGridView1_DataError(object sender, GridViewDataErrorEventArgs e)
{
    e.Cancel = false;
    if ((e.Exception) is System.Data.NoNullAllowedException)
    {
        RadGridView view = (RadGridView)sender;
        if (view.CurrentRow is GridViewNewRowInfo)
        {
            view.CurrentRow.ErrorText = e.Exception.Message;
//The following line doesnt work when adding a row, as e.RowIndex will equal -1
//(sender as RadGridView).Rows[e.RowIndex].ErrorText = e.Exception.Message;         
            e.ThrowException = false;        
        }
    }
}

Could you provide me with a way to retain all data that was entered into the row before the error. Also to some method of indicating which cell has the error, and also how to shut off that exclamation icon when the ErrorText is set or have it be the only icon showing?

Attached are pictures to illustrate how the icon is appearing within the row and showing the tooltip with the empty record
Jack
Telerik team
 answered on 03 Aug 2011
2 answers
134 views
Hi everyone!

I've just installed the Controls for WinForm Q2 2011 and everything appears as expected in VS2008, but i'm missing the RichtTextBox in the toolbox. Even by trying to manually add an element to the toolbox i can't find the new RichTextBox by searching all available .net Framwork Components. Is there any trick i don't know?

Best Regards,
Michael
Michael Hilgers
Top achievements
Rank 1
 answered on 03 Aug 2011
1 answer
109 views
In Visual Studio we have added Business Objects as data sources. When we set the default UI to be the RadCheckBox to the bool properties on the business object it automatically binds to the text field.

How can I make it automatically bind to the checked field?

thanks,

gj
Gary
Top achievements
Rank 1
 answered on 02 Aug 2011
2 answers
1.1K+ views

I could use a little help if you can. I am new to Telerik and a relatively new programmer, so please bear with me as I try to explain my goal.

Essentially what I am trying to do is pivot records from a "View" in my database to produce a full year calendar using a radGridView as the container for the output. The radGridView is bound to a seperate SQL Server table. There are 12 records in the table and 33 columns.This table is only used as a template for the radGridView so all fields are null except for the two where I have set the month name and month #. The radGridView is to be used for visualization only and is not meant to allow for direct editing of records. The table I am using for the template has;
* 12 rows
    - One row for each month ( RowIndex + 1 = month of the year)
* 33 Columns
    - One column for the name of the month ( .ColumnIndex 0)
    - One column for each possible day of the month ( .ColumnIndex 1 - 31). The day columns are named 1, 2, ..... ,31 
    - The last column in the grid ( .ColumnIndex 32) has the month number. Used for sorting only.

What I am trying to do is;

  • Loop through each cell where the column index is between 1 and 31;
  • Query a view in my database (There is a date field in the View where I have parted the day, month and year  from the date into seperate columns)
  • Return a record, if it exists, where
    • day =  .ColumnIndex
    • month = Rowindex + 1
    • Year = Textbox2.Text
    • GPID = Textbox1.Text
    • Set the Cell value to the string returned from the database

The "View" I am querying has 6 columns; GPID, AttDate, aDay, aMonth, aYear, Incidents

The following code works except that it sets each cell value in the columns to the first matching record it finds in the database.

 

Private Sub radGridView1_CellFormatting()
        Dim selectedIndex As Integer = Me.RadGridView1.Rows.IndexOf(Me.RadGridView1.CurrentRow)
        Dim selectedcolumn As Integer = Me.RadGridView1.CurrentCell.ColumnIndex
        Dim EE As Integer
        Dim vbDay As Integer 'Day of the month, also the name of the column
        Dim vbMonth As Integer ' Month of the year, also row index + 1
        Dim vbYear As Integer 'Year being generated
        EE = CInt(TextBox1.Text) ' Employee id #
        vbYear = CInt(TextBox2.Text) 'Year for calendar
  
        For Each row As GridViewDataRowInfo In RadGridView1.Rows
            If Me.RadGridView1.CurrentCell.ColumnIndex > 0 and Me.RadGridView1.CurrentCell.ColumnIndex < 32 Then
                vbDay = selectedcolumn
                vbMonth = selectedIndex + 1
                row.Cells("1").Value = GetEntry(EE, vbDay, vbMonth, vbYear) 'Testing with only a couple of columns.
                row.Cells("2").Value = GetEntry(EE, vbDay, vbMonth, vbYear) 
                      ' ......
            End If
        Next
    End Sub
  
    Public Function GetEntry(ByVal EE As Integer, ByVal vbDay As Integer, ByVal vbMonth As Integer, ByVal vbYear As Integer)
        Dim CalEntry As String
        Dim connstring As String = ("Data Source=MyComputer\SQLEXPRESS;Initial Catalog=MAPPSQL;Persist Security Info=True;User ID=myuser;Password=mypass")
        Dim SelectSQLInc As String = ("Select Incidents From View_AttCombined Where (GPID like '" & EE & "') and (aDay like '" & vbDay & "') and (aMonth like '" & vbMonth & "')and (aYear like '" & vbYear & "')")
        Dim MySDA As New SqlDataAdapter
        Dim DBconn As New SqlConnection(connstring)
        Dim myCom As New SqlClient.SqlCommand(SelectSQLInc, DBconn)
        Dim MyDS As New DataSet
        DBconn.Open()
        MySDA.SelectCommand = myCom
        MySDA.Fill(MyDS)
        DBconn.Close()
        Try
            CalEntry = MyDS.Tables(0).Rows(0).Item(("Incidents").ToString)
        Catch ex As Exception
            CalEntry = "" 'Return nothing if no matching record is found.
        End Try
  
        Return CalEntry
  
    End Function

 
What would I change to loop through each cell one at the time and set the value to the value returned from GetEntry?

Thanks for the help. Let me know if I have totally confused you and need to clarify myself.

 

Julian Benkov
Telerik team
 answered on 02 Aug 2011
1 answer
187 views
I thought I would contribute this proof of concept code I had to work out.  A single cell in a grid needed to update data via a call to a remote system.  However, if the grid had thousands of records, I did not want it to make thousands of remote calls on load.  So, I looked at the ViewCellFormatting event which allows me to retrieve the data only when the cell is visible.  

I also "cached" the data in the cell by setting its flag to "UPDATED".  The "Refresh Data" function actually loops through all rows, clears the cells' tags, and sets the value to zero.  When the visible cell's value is changed, the ViewCellFormatting event is fired and the remote call is made again.

In this proof of concept code, I am simply just updating the row to the current time's Second.  The first button refreshes the data and makes the other non-visible cell's stale by removing the tag.  

The second button will show the "i" count to prove the "remote" call is called only on the visible cells.

I tip my hat to Telerik for this pretty powerful and useful functionality!


Imports Telerik.WinControls.UI
 
 
 
Public Class Form1
 
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        i = 0
        For Each oRow As GridViewDataRowInfo In RadGridView1.Rows()
            oRow.Cells(0).Tag = ""
            oRow.Cells(0).Value = 0
        Next
 
    End Sub
 
 
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        CreateFormControls()
 
        Dim list As New ArrayList()
        Dim i As Integer = 0
        While i < 55
            list.Add(New ValueType(Of Integer)((i + 1)))
            '         System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
            i += 1
        End While
        Me.RadGridView1.DataSource = list
 
    End Sub
 
 
    Private Sub CreateFormControls()
        Me.RadGridView1 = New Telerik.WinControls.UI.RadGridView()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.Button2 = New System.Windows.Forms.Button()
        '
        'RadGridView1
        '
        Me.RadGridView1.Location = New System.Drawing.Point(13, 13)
        Me.RadGridView1.Name = "RadGridView1"
        Me.RadGridView1.Size = New System.Drawing.Size(267, 194)
        Me.RadGridView1.TabIndex = 0
        Me.RadGridView1.Text = "RadGridView1"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(13, 213)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(252, 23)
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "Refresh Viewable Cells...Make other cell stale"
        Me.Button1.UseVisualStyleBackColor = True
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(12, 242)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(136, 23)
        Me.Button2.TabIndex = 1
        Me.Button2.Text = "Total Data Updates"
        Me.Button2.UseVisualStyleBackColor = True
        '
        'Form1
        '
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.RadGridView1)
 
 
    End Sub
 
    Public Class ValueType(Of T)
        Private item As T
        Public Sub New()
        End Sub
        Public Sub New(ByVal item As T)
            Me.item = item
        End Sub
        Public Property ItemProperty() As T
            Get
                Return Me.item
            End Get
            Set(ByVal value As T)
                Me.item = value
            End Set
        End Property
    End Class
 
 
    Private Sub RadGridView1_ViewCellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.ViewCellFormatting
 
        If e.ColumnIndex = 0 Then
            If e.Row.Cells(0).Tag <> "UPDATED" Then
                e.CellElement.Value = Now.Second
                e.Row.Cells(0).Tag = "UPDATED"
                i += 1
            End If
        End If
 
    End Sub
 
    Dim i As Integer
    Private Sub Button2_Click(sender As Object, e As System.EventArgs) Handles Button2.Click
        MsgBox("Date Update Called " & i & " times")
    End Sub
End Class

Stefan
Telerik team
 answered on 02 Aug 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)
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?