Telerik Forums
UI for WinForms Forum
1 answer
97 views
After upgrading to 2008 Q2 my application crashes in several grid event handlers.

For example the CellFormatting event is now also fired for the Filter Row and when the event handler wants to get the data for the cell, it's obviously Null when the grid loads and no filter is set.

If there are there are other breaking changes to the Grid, please update the documentation.

Worked Pre Q2:
       void _grid_CellFormatting(object sender, CellFormattingEventArgs e)  
        {  
            if (e.CellElement.ColumnInfo is GridViewDataColumn && !(e.CellElement.RowElement is GridTableHeaderRowElement))  
 
            {  
 
                GridViewDataColumn column = (GridViewDataColumn)e.CellElement.ColumnInfo;  
 
                if (column.FieldName == "Minutes")  
                {  
                    int minutes = (int)e.CellElement.RowInfo.Cells["Minutes"].Value;  
                    TimeSpan ts = TimeSpan.FromMinutes(minutes);  
                    e.CellElement.Text = string.Format("{0:00}:{1:00}", ts.Hours, ts.Minutes);  
 
 
 
 

Now have to add an additional test (plus additional test of NULL returned by the DB which is not currently possible by the Data Definition).

      void _grid_CellFormatting(object sender, CellFormattingEventArgs e)  
        {  
            if (e.CellElement.ColumnInfo is GridViewDataColumn && (!(e.CellElement.RowInfo is GridViewFilteringRowInfo)) &&                                  
                (!(e.CellElement.RowElement is GridTableHeaderRowElement)))  
            {  
 
                GridViewDataColumn column = (GridViewDataColumn)e.CellElement.ColumnInfo;  
 
                if (column.FieldName == "Minutes")  
                {  
                    if(e.CellElement.RowInfo.Cells["Minutes"].Value!=null)  
                    {  
                        int minutes = (int)e.CellElement.RowInfo.Cells["Minutes"].Value;  
                        TimeSpan ts = TimeSpan.FromMinutes(minutes);  
             

regards
Erwin
Jack
Telerik team
 answered on 06 Jul 2009
9 answers
663 views
Hello,

Is there an easy way to reset the Grid Layout to its default layout?

Thanks,
Tommy
Nick
Telerik team
 answered on 06 Jul 2009
5 answers
131 views
Hello Telerik Team,

I encountered this issue: If you
- open a RadDateTimePicker
- select a date
- open it again and
- select the same date again,
the picker will show January the 1st, 1980.

Have a nice weekend,
STB


Boryana
Telerik team
 answered on 06 Jul 2009
2 answers
246 views

I have an image cell where the image is added conditionally using CellFormatting:

Private Sub RadGridView1_CellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.CellFormatting

        Try

 

            If e.CellElement.ColumnIndex = 1 Then

                If CType(e.CellElement.RowInfo.Cells("type").Value = 0, Decimal) Then

                    e.CellElement.Image = Me.ImageList1.Images(0)

                ElseIf CType(e.CellElement.RowInfo.Cells("type").Value = 1, Decimal) Then

                    e.CellElement.Image = Me.ImageList1.Images(1)

                ElseIf CType(e.CellElement.RowInfo.Cells("type").Value = 2, Decimal) Then

                    e.CellElement.Image = Me.ImageList1.Images(2)

                ElseIf CType(e.CellElement.RowInfo.Cells("type").Value = 3, Decimal) Then

                    e.CellElement.Image = Me.ImageList1.Images(3)

                Else

                    e.CellElement.Image = Me.ImageList1.Images(3)

                End If

            End If

            e.CellElement.DrawFill = True

            If Not IsDBNull(e.CellElement.RowInfo.Cells("Status").Value) Then

                e.CellElement.DrawFill = True

                Select Case (e.CellElement.RowInfo.Cells("Status").Value)

                    Case 23

                        e.CellElement.BackColor = Color.Pink

                    Case 24

                        e.CellElement.BackColor = Color.Chartreuse

                    Case 25

                        e.CellElement.BackColor = Color.Yellow

                    Case 26

                        e.CellElement.BackColor = Color.SkyBlue

                    Case 27

                        e.CellElement.BackColor = Color.LightCyan

                    Case 28

                        e.CellElement.BackColor = Color.Crimson

                    Case 29

                        e.CellElement.BackColor = Color.Blue

                    Case 30

                        e.CellElement.BackColor = Color.Red

                    Case Else

                End Select

            Else

                e.CellElement.BackColor = Color.WhiteSmoke

            End If

 

        Catch ex As Exception

            MsgBox(Err.Description)

        End Try

    End Sub

This colours the whole row I only want the background behind the image to have the colour applied how do I do this?

Regards
Joe

Joe Bohen
Top achievements
Rank 1
 answered on 04 Jul 2009
7 answers
733 views
Hello,

Q1 2009 Winform controls.

I am having a little trouble with wrapping text and autosizing rows.   I have a gridview on a form with a checkbox at the top to define whether to show the full cell text or not.

As far as wrapping text and the rows autosizing, I cannot even get this to work correctly. The problems are:

1..Wrapping of text and resizing of rows only seems to work correctly if the line this.radGridViewExceptions.MasterGridViewTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; is not commented out.  If this is commented out and I set the column widths in the swtich, the description column, which has the most text, only shows 2 lines of text fully. The 3rd and final line in that cell shows about 10% of the top of the 3rd line, the rest is cut off.

2..The cursor changes to an arrow pointing up and down, like it is going to let me resize the row, but I cannot resize it even though AllowResize is set to true in the designer properties

3...My functional requirement is that on clicking the checkbox to not show full text, the rows go back to only show one line of text and do not wrap.  So in the event handler for the checkbox I go through the columns in the grid and set WrapText to the checked state of the checkbox.  This either enables or disables wrapping ok, but the row height when going from wraptext =true to wraptext = false does not change so I am left with thick and thin rows.  I want all rows to be thin, ie all the same height.

Thanks in advance,

My code is below:

     private void SetupForm() 
        { 
            try 
            { 
                // Add the events 
                this.radGridViewExceptions.ViewCellFormatting += new Telerik.WinControls.UI.CellFormattingEventHandler(radGridViewExceptions_ViewCellFormatting); 
                this.radGridViewExceptions.DataSource = m_objExceptions.GetLast30DaysExceptions(); 
               
                // Wrapping text only seems to work correctly if this is not commented out
                // and I do not set the column widths below
                // this.radGridViewExceptions.MasterGridViewTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; 
               
                this.radGridViewExceptions.MasterGridViewTemplate.AllowColumnReorder = false
                this.radGridViewExceptions.MasterGridViewTemplate.AllowColumnResize = false
                this.radGridViewExceptions.AutoSizeRows = true
 
                // Format the columns 
                foreach (GridViewColumn column in radGridViewExceptions.Columns) 
                { 
                    switch (column.HeaderText) 
                    { 
                        case "When_Occured": 
                        case "Description": 
                            column.Width = 200
                            break; 
 
                        case "App_Assembly": 
                            column.Width = 120
                            break; 
 
                        case "App_Assembly_Version": 
                            column.Width = 150
                            break; 
 
                        default: 
                            column.Width = 100
                            break; 
                    } 
 
                    column.WrapText = true; //radCheckBoxShowFullText.Checked; 
                } 
                m_bFormLoaded = true
            } 
            catch (Exception ex) 
            { 
                ShowException(ex); 
                m_bFormLoaded = false
            } 
        } 
 

 


Victor
Telerik team
 answered on 03 Jul 2009
1 answer
238 views
Hi

I'm on a tight schedule and have put many hours of work into a usercontrol that does a bunch of stuff, automatic syntax highlighting based on list and db lookups, validation as you type and so on and so forth.

I did all of this on the assumption that, like the control set I worked with in my previous job, the Telerik Grid would provide some means of created a custom column that used my control.

However, having started work on the actual grid, I can find no way of doing this. After my initial efforts bore no fruit I searched extensively for ways of doing it both here and elsewhere on the Web and found nothing.

The code fragments I have found all require that one uses a class that is inherited from RadElement. Since the control I have, which represents many hours of work, is already written and I'm on a tight schedule, I _don't_ want to rewrite the whole thing from scratch based on a RadElement derived control. And C# doesn't allow multiple inheritance.

So the only thing I can think of is to somehow wrap my usercontrol in a class inherited from RadElement. My assumption is that it is possible to override certain painting and editing events inherited from the RadElement class so that they present my usercontrol. But the documentation of RadElement's members is kinda minimal - auto-documented code minimal. There's no explanation of what any of the events or functions are FOR, just descriptions of their signatures.

Is what I'm attempting possible? If so, how do I proceed?

Thanks in anticipation :)
Jack
Telerik team
 answered on 03 Jul 2009
1 answer
174 views
Hi!

I have been working for 2 days now trying to solve a basic "2 way binding" problem but I'm about to give up.
Is this possible with todays RadGridView?

We are working on a enterprise application with a n-tire layer architecture.

Data Access Layer
Business Logic Layer
GUI

The Data Access Layer is using Linq2SQL to get the data from the database and then passes the linq objects to the business layer and then the gui layer.
In the gui layer we have a RadGridView.

The RadGridView is readonly from start.
After the user clicks on a "Start edit" button, the RadGridView can be edited.

I want the user to be able to edit fields, remove rows and add new rows but nothing should be changed in the database until the user presses the button "Save changes".

Can this be done?
Can someone please send me a "best practice" example for this, I cannot be the only one looking for this?

Regards,
Per Bornsjö

Jordan
Telerik team
 answered on 03 Jul 2009
1 answer
213 views
Hi, I have a RadGridView that is bound to a DataTable.
I refresh the data binding every 30 seconds.
Currently before I refresh I store the currently selected rows and reselect them on rebinding to make the user experience as seamless as possible.
This works fine until I have enough items to cause it to scroll. When I have items selected at the bottom of the list, on refresh the selection disappears even though I have it added to the selectedrows collection, and the scrollbar is at the top with the item out of view. When I manually scroll down, I see that my previous selection has disappeared.
Also I tried using the code below as suggested in the forum to scroll to my selected row.
int visualRowsCount = this.radGridView1.GridElement.VisualRows.Count;   
  
this.radGridView1.GridElement.ScrollToRow(indexToScroll - visualRowsCount + 3);  
But my visualrows.count is always returned as zero. And when I call the ScrollToRow method, it always gives an outofbounds exception.
I am using the binding below where docs is a DataTable.
this.gridDocs.MasterGridViewTemplate.Columns.Clear(); 
this.gridDocs.MasterGridViewTemplate.DataSource = docs
Am I doing something wrong here?
Jack
Telerik team
 answered on 03 Jul 2009
5 answers
517 views
I'm using RadControls for WinForms 2008.3 1321 (control version 8.2.0.0) and found the following issue:

The SelectedValueChanged event of the RadComboBox fires two times when the item selection changes. I'm able to reproduce this with the following small WinForms test project:

Form1.Designer.cs
namespace RadComboTest 
    partial class Form1 
    { 
        /// <summary> 
        /// Required designer variable. 
        /// </summary> 
        private System.ComponentModel.IContainer components = null
 
        /// <summary> 
        /// Clean up any resources being used. 
        /// </summary> 
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 
        protected override void Dispose(bool disposing) 
        { 
            if (disposing && (components != null)) 
            { 
                components.Dispose(); 
            } 
            base.Dispose(disposing); 
        } 
        #region Windows Form Designer generated code 
 
        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor. 
        /// </summary> 
        private void InitializeComponent() 
        { 
            this.radComboBox1 = new Telerik.WinControls.UI.RadComboBox(); 
            ((System.ComponentModel.ISupportInitialize)(this.radComboBox1)).BeginInit(); 
            this.SuspendLayout(); 
            //  
            // radComboBox1 
            //  
            this.radComboBox1.Location = new System.Drawing.Point(12, 12); 
            this.radComboBox1.Name = "radComboBox1"
            //  
            //  
            //  
            this.radComboBox1.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren; 
            this.radComboBox1.Size = new System.Drawing.Size(260, 20); 
            this.radComboBox1.TabIndex = 0; 
            this.radComboBox1.Text = "radComboBox1"
            //  
            // Form1 
            //  
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
            this.ClientSize = new System.Drawing.Size(284, 264); 
            this.Controls.Add(this.radComboBox1); 
            this.Name = "Form1"
            this.Text = "Form1"
            ((System.ComponentModel.ISupportInitialize)(this.radComboBox1)).EndInit(); 
            this.ResumeLayout(false); 
            this.PerformLayout(); 
 
        } 
        #endregion 
 
        private Telerik.WinControls.UI.RadComboBox radComboBox1; 
    } 
 
 

Form1.cs
using System; 
using System.Diagnostics; 
using System.Windows.Forms; 
using Telerik.WinControls.UI; 
 
namespace RadComboTest 
    public partial class Form1 : Form 
    { 
        public Form1() 
        { 
            InitializeComponent(); 
 
            radComboBox1.Items.Add(new RadComboBoxItem("Item1", 1)); 
            radComboBox1.Items.Add(new RadComboBoxItem("Item2", 2)); 
            radComboBox1.Items.Add(new RadComboBoxItem("Item3", 3)); 
 
            radComboBox1.SelectedValueChanged += new EventHandler(radComboBox1_SelectedValueChanged); 
        } 
 
        void radComboBox1_SelectedValueChanged(object sender, EventArgs e) 
        { 
            Debug.Fail("radComboBox1_SelectedValueChanged"); 
        } 
    } 
 

Can anybody confirm this issue?

Regards,
ReneMT


gmendez
Top achievements
Rank 1
 answered on 02 Jul 2009
1 answer
395 views
Hello Telerik support,

I realize this was discussed on this forum back in June '07, but didn't reach a conclusion.  I'm trying to simply set input focus to a radTextBox like so:

private

void Form_Load(object sender, EventArgs e)

 

{
    this.radTextBox.Focus();

}

The cursor does not get set onto the radTextBox.  What needs to be done here?


Thanks!
Jeremy

Nikolay
Telerik team
 answered on 02 Jul 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
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
SplitContainer
Documentation
Map
DesktopAlert
CheckedDropDownList
ProgressBar
MessageBox
TrackBar
Rotator
SpinEditor
CheckedListBox
StatusStrip
CollapsiblePanel
LayoutControl
ShapedForm
SyntaxEditor
Wizard
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
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?