Telerik Forums
UI for WinForms Forum
11 answers
285 views

Hi!

 


VERSION: 2010 Q2 SP2

This is my simple application:

 


EditableCheckBoxCellElement:

 

  

namespace GridViewUnboundMode
{
    public class EditableCheckBoxCellElement : GridDataCellElement
    {
        private RadCheckBoxElement _chk;
        private RadTextBoxElement _txtBox;
  
        private CellValue _cellValue;
  
        public EditableCheckBoxCellElement(GridViewColumn column, GridRowElement row)
            : base(column, row)
        {
        }
  
        protected override void CreateChildElements()
        {
            base.CreateChildElements();
  
            _chk = new RadCheckBoxElement();
            _chk.Margin = new Padding(2, 2, 2, 2);
            _chk.MinSize = new Size(10, 10);
            _chk.Text = string.Empty;
            _chk.ToggleState = Telerik.WinControls.Enumerations.ToggleState.Off;
            _chk.ToggleStateChanged += new StateChangedEventHandler(_chk_ToggleStateChanged);
  
            _txtBox = new RadTextBoxElement();
            _txtBox.Margin = new Padding(2, 2, 2, 2);
            _txtBox.MinSize = new Size(10, 10);
            _txtBox.Text = "sss";
  
            this.Children.Add(_chk);
            this.Children.Add(_txtBox);
        }
  
  
        void _chk_ToggleStateChanged(object sender, StateChangedEventArgs args)
        {
            if (_chk.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
            { _cellValue.IsAssigned = true; }
            else if (_chk.ToggleState == Telerik.WinControls.Enumerations.ToggleState.Off)
            { _cellValue.IsAssigned = false; }
        }
  
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            if (this.Children.Count == 2)
            {
                this.Children[0].Arrange(new RectangleF(2, 2, 10, 10));
                this.Children[1].Arrange(new RectangleF(21, 2, finalSize.Width - 28 - 10, 15));
            }
            return finalSize;
        }
  
        public override object Value
        {
            get { return _cellValue; }
            set
            {
                _cellValue = value as CellValue;
                if (_cellValue != null)
                {
                    _txtBox.Text = _cellValue.Text;
                    this.IsChecked = _cellValue.IsAssigned;
                }
            }
        }
  
        public bool IsChecked
        {
            get
            {
                return _cellValue.IsAssigned;
            }
            set
            {
                if (value)
                { _chk.ToggleState = Telerik.WinControls.Enumerations.ToggleState.On; }
                else
                { _chk.ToggleState = Telerik.WinControls.Enumerations.ToggleState.Off; }
                _cellValue.IsAssigned = value;
            }
        }
  
    }
}

EditableCheckBoxColumn:

 

 


namespace GridViewUnboundMode
{
    public class EditableCheckBoxColumn : GridViewDataColumn
    {
        public EditableCheckBoxColumn(): base()
        {
        }
   
        public override Type GetCellType(GridViewRowInfo row)
        {
            if (row is GridViewDataRowInfo)
            {
                return typeof(EditableCheckBoxCellElement);
            }        
            return base.GetCellType(row);
        }
    }
}

CellValue:

namespace GridViewUnboundMode
{
    public class CellValue
    {
        public string Text { get; set; }
        public bool IsAssigned { get; set; }
    }
}

Form1:

namespace GridViewUnboundMode
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            radGridView1.MultiSelect = true;
            radGridView1.AllowColumnChooser = false;
  
            GridViewDataColumn columnCSname = new GridViewTextBoxColumn();
            columnCSname.HeaderText = "Standard column";
            radGridView1.Columns.Add(columnCSname);
            columnCSname.Width = 160;
            columnCSname.ReadOnly = true;
  
            this.AddCustomColumns(4);
            this.AddNewRow();
            this.AddNewRow();
  
            columnCSname.IsPinned = true;
        }
  
        private void AddNewRow()
        {
            GridViewRowInfo rowInfo = this.radGridView1.Rows.AddNew();
            int columnIndex = 0;
            foreach (GridViewCellInfo cellInfo in rowInfo.Cells)
            {
                if (cellInfo.ColumnInfo.Index == 0)
                {
                    cellInfo.Value = string.Format("Standard column, Col: {0}, Row: {1}", cellInfo.ColumnInfo.Index, rowInfo.Index);
                }
                else
                {
                    CellValue cellValue = new CellValue();
                    cellValue.Text = string.Format("Col: {0}, Row: {1}", cellInfo.ColumnInfo.Index, rowInfo.Index);
  
                    cellInfo.Tag = cellValue;
                }
                columnIndex++;
            }
        }
  
        private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
        {
            EditableCheckBoxCellElement cellElement = e.CellElement as EditableCheckBoxCellElement;
            if (cellElement != null)
            {
                CellValue val = e.CellElement.RowInfo.Cells[e.CellElement.ColumnIndex].Tag as CellValue;
                cellElement.Value = val;
            }
        }
  
        private void AddCustomColumns(int count)
        {
            for (int index = 0; index < count; index++)
            {
                GridViewDataColumn newColumn = new EditableCheckBoxColumn();
                newColumn.HeaderText = "Col" + (radGridView1.Columns.Count + 1).ToString();
                newColumn.Name = newColumn.HeaderText;
                newColumn.Width = 120;
                if (radGridView1.Columns.Count == 0)
                { newColumn.IsPinned = true; }
                radGridView1.Columns.Add(newColumn);
            }
        }
    }
}

 

 

 

 


When I run application I see form from attachment viewAfterStartup.JPG. “Standard column” is pinned at left.

 


FIRST PROBLEM

 

If I resize window to smaller size then I have scroll bar on the bottom.

When I start scrolling to right I have problem with text box from custom cells – it overlaps on “Standard column”. This is weird because this problem is only for text box, for check box it is ok (check box does not overlap pinned column) – please check attachments “scrollingCheckBox-OK.JPG” and “scrollingTextBox-NOTok.JPG”. What is wrong in my source code?

 



SECOND PROBLEM

 

When I unpin “Standard column” I see in this column cells of class EditableCheckBoxCellElement. How it is possible? Name of column is correct but cells change type. Check attachment “unpinnedFirstColumn.JPG”.

 



Regards

Raymond
Top achievements
Rank 1
 answered on 05 Nov 2010
3 answers
116 views
Hi there,

Just a quick question for you all:  How can I get access to the SystemRows or the header row/cells of a child collection that's empty?  Generally if I wanted to access those guys for a row that already exists I'd go

((GridViewDataRowInfo)row).ViewInfo.SystemRows

or

((GridViewDataRowInfo)row).ViewInfo.TableHeaderRow

respectively, but I can't figure out how to get access to those guys for an empty child collection because there's no "row" object I can latch onto if the parent's ChildRows is empty.  I know they exist somewhere though because they're sitting there on my screen.  I just feel like I must be missing something simple.

For reference, I'd like to set the child NewRow as the currently selected row when a new hierarchy row is created (so insertion would drill through the hierarchy, following the way my users would prefer to enter data) and I need to force an InvalidateRow on a child HeaderRow so that it fires the ViewCellFormatting event when the value of a certain cell is changed (so I can set the header text of the child view even if there are no children yet).

As an aside, in an attempt to solve the second issue I've tried to fire the grid.TableElement.Update() method with a parameter of GridUINotifyAction.Reset and GridUINotifyAction.DataChanged in my grid_CellValueChanged event, and it's throwing exceptions up to my Main method (bypassing my try/catch around the actual Update() call).  Not sure if that's intentional/expected.

Thanks for any direction!
Brian Manning
Top achievements
Rank 1
 answered on 05 Nov 2010
1 answer
145 views
Hey, not sure if I am missing something here, but I am not finding any way to add a new value to the underlying data source when user types a value into the drop down list that does not currently exist. 

I mean, I have my own code that will handle this, I am jsut trying to determine the best time to do what is needed - if the user types in a value that does not exist in data bound list would it make sense to have the code in the TextChanges event, in the Validating event, or somewhere else?

Thanks!

Justin
Emanuel Varga
Top achievements
Rank 1
 answered on 05 Nov 2010
6 answers
132 views
Afternoon,

I've just got a strange behaviour from my gridviews. I recently updated my dataset and went about rebinding everything.

Since then however I have noticed that the alternating row colour no longer works. I am using the default colours.

The property window was telling me that it was set to true so I set this back to false and then to true again incase it had lost its setting but this changed nothing.

I have also set it to false/true inside both the property builder and set programmatically with the same result. I have also tried reopening the project.

Little bit stumped on this one, any one got any ideas?

Kind regards,

Guy
Richard Slade
Top achievements
Rank 2
 answered on 05 Nov 2010
1 answer
119 views
Hi,

I have a hierarchical grid and on the child grids (if there are more than one) on the same level, I'll get some nice captions as Tabs. Now I want these Tabs/Captions also for childgrids where only one grid at a specified level is and also for the MasterGridViewTemplate.

I'm setting already the captions, how can I show them?

Thanks,
Michael
Jack
Telerik team
 answered on 05 Nov 2010
7 answers
282 views
Morning,

I think this question is not directly Telerik related but hopefully someone can help.

I have a datepicker and gridview databound. When I select a row on the gridview, the datepicker updates as I would expect but if I select a row with a blank date (DBNull I believe?) then it still retains the avlue from the previously picked date but still treats it as a null value.

I have looked through all the options I can think of in Formatting and Advanced Binding but nothing seems to work. I have also looked at ways of refreshing the databinding on row change but got no where (plus I don't think that's really the correct way of doing things).

If anyone could help or point me in the right direction i'd really appreciate it!

Kind regards,


Guy
Richard Slade
Top achievements
Rank 2
 answered on 04 Nov 2010
3 answers
79 views
Hi All,
I have a project developed in .NET 3.5 framework using Rad Controles Winfoms Q1. I want to confirm that project developed using Rad Controls Winforms Q1 is compatable with Rad Controls winforms Q2 2010 with out any chane in code. 

Thanks
Vijay
Stefan
Telerik team
 answered on 04 Nov 2010
4 answers
761 views
I have multiple grids with 100,000+ rows in them. I found that allowing RadViewGrid control to do the sorting is very slow and freezes the application while sorting. I am thinking about implementing a SortableBindingList and do my sorting outside the grid and force it to show the newly sorted BindingList when done.

However, this means I have to turn sorting off in the grid, loosing the sort indicator and the context menu options for sorting.

What would you suggest in this scenario?

Thanks,

Phi
Julian Benkov
Telerik team
 answered on 04 Nov 2010
5 answers
1.1K+ views

Hi all,

I am experimenting some troubles in speeding up the filling of a RadGridView. If I fill it row by row (Add method) the result is correct but slow (more than 10s for 300 rows). If I create a GridViewRowInfo array and then fill the Grid with AddRange the task is completed istantaneously, but then the result differs from the one obtained through the Add method (problems in row selection and column resize, not depending on the AllowX properties). In particular I think the my errors are in creating each GridViewRowInfo, that needs a GridViewInfo that needs a GridViewTemplate. Here the code:

GridViewTemplate template = new GridViewTemplate();
template.AllowColumnResize = true;
 
foreach (GridViewColumn col in myGrid.Columns)
  template.Columns.Add((GridViewDataColumn)col);
 
GridViewInfo info = new GridViewInfo(template);
GridViewRowInfo row = new GridViewRowInfo(info);
row.AllowResize = true;
 
// oRow contains the values for the cells
for (int i = 0; i < oRow.Length; i++)
  row.Cells[i].Value = oRow[i]; 
 
row.Tag = epropSample;

Hope someone could help!
Thanks in advance!
Roberto
Roberto
Top achievements
Rank 1
 answered on 04 Nov 2010
5 answers
164 views
I often use image with Telerik controls such MenuItem, buttons, ect. via the Image property or BackgroundImage property.

Do I need to dispose of these images myself?

Thanks,

Phi
Richard Slade
Top achievements
Rank 2
 answered on 04 Nov 2010
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?