To reproduce: use the following code snippet and follow the steps illustrated on the attached gif file:
private void Form1_Load(object sender, EventArgs e)
{
this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
this.radGridView1.DataSource = this.customersBindingSource;
this.radGridView1.BestFitColumns(BestFitColumnMode.AllCells);
ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
view.ColumnGroups.Add(new GridViewColumnGroup("Customer Contact"));
view.ColumnGroups.Add(new GridViewColumnGroup("Details"));
view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Address"));
view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Contact"));
view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["CompanyName"]);
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ContactName"]);
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ContactTitle"]);
view.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Address"]);
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["City"]);
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Country"]);
view.ColumnGroups[1].Groups[1].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Phone"]);
view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Fax"]);
radGridView1.ViewDefinition = view;
}
Sometimes the incorrect behavior is obtained immediately after you drop the column, but you need to scroll the horizontal scroll-bar to replicate it.
Workaround:
RadGridViewDragDropService svc = this.radGridView1.GridViewElement.GetService<RadGridViewDragDropService>();
svc.Stopped += svc_Stopped;
private void svc_Stopped(object sender, EventArgs e)
{
int horizontalScrollvalue = this.radGridView1.TableElement.HScrollBar.Value;
this.radGridView1.MasterTemplate.Refresh();
this.radGridView1.TableElement.HScrollBar.Value = horizontalScrollvalue;
}
To reproduce: use the following code snippet and refer to the attached gif file:
public Form1()
{
InitializeComponent();
for (int i = 0; i < 20; i++)
{
this.radGridView1.Columns.Add("Col" + i);
}
for (int i = 0; i < 10; i++)
{
GridViewDataRowInfo row = this.radGridView1.Rows.AddNew() as GridViewDataRowInfo;
foreach (GridViewColumn col in this.radGridView1.Columns)
{
row.Cells[col.Name].Value = "Data" + row.Index + "." + col.Index;
}
}
this.radGridView1.MultiSelect = true;
this.radGridView1.SelectionMode = GridViewSelectionMode.CellSelect;
}
Workaround:
int startColumn = int.MaxValue;
int endColumn = 0;
int startRow = int.MaxValue;
int endRow = 0;
private void radGridView1_MouseDown(object sender, MouseEventArgs e)
{
GridDataCellElement cellElement = this.radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement;
if (cellElement != null)
{
startColumn = cellElement.ColumnIndex;
startRow = cellElement.RowIndex;
}
}
private void radGridView1_MouseUp(object sender, MouseEventArgs e)
{
GridDataCellElement cellElement = this.radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement;
if (cellElement != null)
{
endColumn = cellElement.ColumnIndex;
endRow = cellElement.RowIndex;
}
if (endColumn < startColumn)
{
int swap = endColumn;
endColumn = startColumn;
startColumn = swap;
}
if (endRow < startRow)
{
int swap = endRow;
endRow = startRow;
startRow = swap;
}
this.radGridView1.ClearSelection();
int scrollBarValue = this.radGridView1.TableElement.HScrollBar.Value;
this.radGridView1.BeginUpdate();
for (int i = startRow; i < endRow + 1; i++)
{
for (int j = startColumn; j < endColumn + 1; j++)
{
if (!this.radGridView1.Rows[i].Cells[j].IsSelected)
{
this.radGridView1.Rows[i].Cells[j].IsSelected = true;
}
}
}
this.radGridView1.EndUpdate();
this.radGridView1.TableElement.HScrollBar.Value = scrollBarValue;
}
Hello,
I succeed to reproduce the GridViewComboboxColumn exception in this forum post:
http://www.telerik.com/forums/nullreferenceexception-4a6181b2453b#cwDrbIqzp0CPxcgh90b4rQ
I attach a sample project, the database (SQL Server 2012 Express) and a video from the exception.
To reproduce:
- Run the project,
- Sort the column "Állapot" descending.
- Click on column and drop down the list.
- Choose an another value, and click very fast twice. On a slow PC is much easier to reproduce the issue. The important thing, that you need select a value from the combobox and select another row very fast. (See the attached video)
I use the latest Trial version of Winforms.
If you have any question, please contact me.
Best Regards,
László
Workaround:
Private Sub gridMunkak_CreateCell(sender As Object, e As GridViewCreateCellEventArgs) Handles gridMunkak.CreateCell
If e.CellType = GetType(GridComboBoxCellElement) Then
e.CellElement = New MyGridComboBoxCellElement(e.Column, e.Row)
End If
End Sub
Public Class MyGridComboBoxCellElement
Inherits GridComboBoxCellElement
Public Sub New(column As GridViewColumn, row As GridRowElement)
MyBase.New(column, row)
End Sub
Public Overrides Sub SetContent()
If Me.ColumnInfo IsNot Nothing Then
MyBase.SetContent()
End If
End Sub
Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
Get
Return GetType(GridComboBoxCellElement)
End Get
End Property
End Class
How to Reproduce:
Source XML:
<?xml version="1.0" encoding="utf-8"?>
<grandparent Date="2014-12-17Z" Name="Grandparent" SchemaVersion="1.0" Time="04:27:07Z" xmlns="">
<parent Name="parent1" City="Los Angeles">
<child Name="Child1" Age="5"/>
<child Name="Child2" Age="8"/>
</parent>
<parent Name="parent2" City="Chicago">
<child Name="Child1" Age="11"/>
<child Name="Child2" Age="15"/>
</parent>
</grandparent>
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
DataSet xmlDataSet = new DataSet();
xmlDataSet.ReadXml(@"..\..\test.xml");
GridViewTemplate parentTemplate = new GridViewTemplate();
this.radGridView1.MasterTemplate.Templates.Add(parentTemplate);
GridViewRelation relation = new GridViewRelation(this.radGridView1.MasterTemplate);
relation.ChildTemplate = parentTemplate;
relation.RelationName = "Grandparent_Parent";
relation.ParentColumnNames.Add("grandparent_Id");
relation.ChildColumnNames.Add("grandparent_Id");
radGridView1.Relations.Add(relation);
this.radGridView1.DataSource = xmlDataSet.Tables[0];
parentTemplate.DataSource = xmlDataSet.Tables[1];
parentTemplate.AllowAddNewRow = false;
GridViewTemplate childTemplate = new GridViewTemplate();
parentTemplate.Templates.Add(childTemplate);
GridViewRelation childRelation = new GridViewRelation(parentTemplate);
childRelation.ChildTemplate = childTemplate;
childRelation.RelationName = "Parent_Child";
childRelation.ParentColumnNames.Add("parent_Id");
childRelation.ChildColumnNames.Add("parent_Id");
radGridView1.Relations.Add(childRelation);
childTemplate.DataSource = xmlDataSet.Tables[2];
}
}
Workaround - set the data sources of the templates last, or use auto generate hierarchy:
this.radGridView1.AutoGenerateHierarchy = true;
DataSet xmlDataSet = new DataSet();
xmlDataSet.ReadXml(@"..\..\test.xml");
this.radGridView1.DataSource = xmlDataSet;
radGridView1.DataMember = "grandparent";
this.radGridView1.AutoGenerateHierarchy = true;
To reproduce: use the following code snippet:
Sub New()
InitializeComponent()
Me.RadGridView1.EnableFiltering = True
Me.RadGridView1.ShowHeaderCellButtons = True
Dim dt As New DataTable
dt.Columns.Add("Id", GetType(Integer))
dt.Columns.Add("Name", GetType(String))
dt.Columns.Add("Type", GetType(String))
dt.Columns.Add("Active", GetType(Boolean))
Dim typeList As New List(Of String)
typeList.Add("REFERRAL")
typeList.Add("EMPLOYEE")
typeList.Add("Type3")
typeList.Add("Type4")
Dim rand As New Random
For index = 1 To 10
dt.Rows.Add(index, "Name" & index, typeList(rand.Next(0, typeList.Count)),If(index mod 2=0, True,false))
Next
Me.RadGridView1.AutoGenerateColumns = False
Dim decimalColumn As New GridViewDecimalColumn("ID")
decimalColumn.FieldName = "Id"
RadGridView1.MasterTemplate.Columns.Add(decimalColumn)
Dim textBoxColumn As New GridViewTextBoxColumn("Name")
textBoxColumn.FieldName = "Name"
RadGridView1.MasterTemplate.Columns.Add(textBoxColumn)
Dim supplierColumn As GridViewComboBoxColumn = New GridViewComboBoxColumn("Type")
supplierColumn.FieldName = "Type"
supplierColumn.DataSource = typeList
Me.RadGridView1.Columns.Add(supplierColumn)
Dim checkBoxColumn As New GridViewCheckBoxColumn("Active")
checkBoxColumn.FieldName = "Active"
RadGridView1.MasterTemplate.Columns.Add(checkBoxColumn)
Me.RadGridView1.DataSource = dt
Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Dim activeFilter As New FilterDescriptor()
activeFilter.PropertyName = "Active"
activeFilter.Operator = FilterOperator.IsEqualTo
activeFilter.Value = True
Dim typeFilter As New CompositeFilterDescriptor()
typeFilter.FilterDescriptors.Add(New FilterDescriptor("Type", FilterOperator.IsEqualTo, "EMPLOYEE"))
typeFilter.FilterDescriptors.Add(New FilterDescriptor("Type", FilterOperator.IsEqualTo, "REFERRAL"))
typeFilter.LogicalOperator = FilterLogicalOperator.Or
Dim overallFilterDescriptor As New CompositeFilterDescriptor()
'overallFilterDescriptor.PropertyName = "Type"
'overallFilterDescriptor.IsFilterEditor = True
overallFilterDescriptor.FilterDescriptors.Add(typeFilter)
overallFilterDescriptor.FilterDescriptors.Add(activeFilter)
overallFilterDescriptor.LogicalOperator = FilterLogicalOperator.And
Me.RadGridView1.FilterDescriptors.Add(overallFilterDescriptor)
End Sub
Run the project and click the button. You will see that the filter button is not orange indicating that there is applied filter. Additionally, the "Clear filter" option is disabled and the user is not allowed to see the entire data any more.
Workaround: set the overall CompositeFilterDescriptor.PropertyName to a specific column and the IsFilterEditor property to true. Thus, you will be allowed to clear the filter from this column.
To reproduce:
- Add some columns to a grid.
- Then add a column like this:
private void button2_Click(object sender, System.EventArgs e)
{
radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
Telerik.WinControls.UI.GridViewDataColumn gridViewColumn2 = new Telerik.WinControls.UI.GridViewCheckBoxColumn();
gridViewColumn2.MinWidth = gridViewColumn2.MaxWidth = 22;
gridViewColumn2.Width = 100;
radGridView1.MasterTemplate.Columns.Add(gridViewColumn2);
gridViewColumn2.MinWidth = 0;
gridViewColumn2.MaxWidth = 0;
}
Please note that if you add two columns with the above code, you will be able to resize the first one, but the cursor position is in wrong position.
Workaround:
- Set the MaxWidth before adding the column to the grid.
To reproduce: - Use RadDock with MDI mode. - Add a form that contains a grid. - Set the theme to Aqua. Workaround: grid.GridViewElement.ForeColor = Color.Black;
To reproduce:
public class ProgressBarCellElement : GridDataCellElement
{
public ProgressBarCellElement(GridViewColumn column, GridRowElement row) : base(column, row)
{
}
private RadProgressBarElement radProgressBarElement;
protected override void CreateChildElements()
{
base.CreateChildElements();
radProgressBarElement = new RadProgressBarElement();
this.Children.Add(radProgressBarElement);
}
protected override void SetContentCore(object value)
{
if (this.Value != null && this.Value != DBNull.Value)
{
this.radProgressBarElement.Value1 = Convert.ToInt16(this.Value);
}
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(GridDataCellElement);
}
}
public override bool IsCompatible(GridViewColumn data, object context)
{
return data is ProgressBarColumn && context is GridDataRowElement;
}
}
public class ProgressBarColumn : GridViewDataColumn
{
public ProgressBarColumn() : base()
{
}
public ProgressBarColumn(string fieldName) : base(fieldName)
{
}
public override Type GetCellType(GridViewRowInfo row)
{
if (row is GridViewDataRowInfo)
{
return typeof(ProgressBarCellElement);
}
return base.GetCellType(row);
}
}
It does not matter the type of the control that we want to move the focus on as well as if it was RadControl or not
To reproduce:
private void radGridView1_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e)
{
e.Cancel = true;
// Some other control to move the focus on
this.textBox1.Focus();
}
Workaround:
Before cancelling the event set the value of the active editor to the current cell value
private void radGridView1_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e)
{
this.radGridView1.ActiveEditor.Value = e.Row.Cells[e.Column.Name].Value;
e.Cancel = true;
// Some other control to move the focus on
this.textBox1.Focus();
}
To reproduce:
private void Form1_Load(object sender, EventArgs e)
{
GridSearchRowElement searchRow = null;
foreach (GridRowElement row in this.radGridView1.TableElement.VisualRows)
{
if (row is GridSearchRowElement)
{
searchRow = row as GridSearchRowElement;
break;
}
}
if (searchRow != null)
{
searchRow.SearchCellElement.SearchBoxWidth = 400;
}
}
Workaround:
radGridView1.TableElement.InvalidateMeasure(true);
radGridView1.TableElement.UpdateLayout();
To reproduce: create a form with a button on it where on its Click event you show another form with the following code snippet:
public class Dummy
{
public int ID { get; set; }
public string Description { get; set; }
}
public Form1()
{
InitializeComponent();
this.radGridView1.FilterChanged += radGridView1_FilterChanged;
if (File.Exists(@"..\..\..\layout.xml"))
{
this.radGridView1.LoadLayout(@"..\..\..\layout.xml");
}
else
{
radGridView1.Columns.Add(new GridViewTextBoxColumn { HeaderText = "Id ", FieldName = "ID" });
radGridView1.Columns.Add(new GridViewTextBoxColumn { HeaderText = "Description", FieldName = "DESCRIPTION" });
}
radGridView1.EnableFiltering = true;
radGridView1.MasterTemplate.ShowHeaderCellButtons = true;
radGridView1.MasterTemplate.ShowFilteringRow = true;
var items = new List<Dummy>();
for (int i = 0; i < 20; i++)
{
var dummy = new Dummy
{
ID = i,
Description = string.Format("Description_{0}", i)
};
items.Add(dummy);
}
radGridView1.AutoGenerateColumns = false;
radGridView1.DataSource = items;
}
private void radGridView1_FilterChanged(object sender, GridViewCollectionChangedEventArgs e)
{
this.radGridView1.SaveLayout(@"..\..\..\layout.xml");
}
Please refer to the attached gif file illustrating the steps.
To reproduce:
1. Add a RadGridView and a RadButton.
2. Populate the grid with data and call the BestFitColumns( BestFitColumnMode.AllCells) method (or resize the columns).
3. Set its RightToLeft property to Windows.Forms.RightToLeft.Yes.
3. In the RadButton.Click event handler call the RadGridView.PrintPreview(). As a result the columns are shrunk. Please see the attached gif file.
Workaround:
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Me.RadGridView1.BeginUpdate()
Me.RadGridView1.PrintPreview()
Me.RadGridView1.EndUpdate()
Me.RadGridView1.BestFitColumns(BestFitColumnMode.AllCells)
End Sub
To reproduce:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CustomersTableAdapter.Fill(Me.NwindDataSet.Customers)
Me.RadGridView1.BestFitColumns(Telerik.WinControls.UI.BestFitColumnMode.AllCells)
Me.RadGridView1.Columns(2).IsPinned = True
Me.RadGridView1.Columns(2).PinPosition = Telerik.WinControls.UI.PinnedColumnPosition.Left
Me.RadGridView1.Columns(5).IsPinned = True
Me.RadGridView1.Columns(5).PinPosition = Telerik.WinControls.UI.PinnedColumnPosition.Left
Dim summaryItem As New GridViewSummaryItem()
summaryItem.Name = "ContactTitle"
summaryItem.Aggregate = GridAggregateFunction.Count
Dim summaryRowItem As New GridViewSummaryRowItem()
summaryRowItem.Add(summaryItem)
Me.RadGridView1.SummaryRowsBottom.Add(summaryRowItem)
Me.RadGridView1.MasterTemplate.ShowTotals = True
Me.RadGridView1.EnableKineticScrolling = True
Me.RadGridView1.MasterView.SummaryRows(0).PinPosition = PinnedRowPosition.Bottom
End Sub
Please refer to the attached gif file.
It would be great if multi-page printing is supported for grids with ColumnGroupsViewDefinition and HtmlViewDefinition.
To reproduce:
- Add checkbox column to a grid and enable filtering.
- Filter on other column so there are no rows visible.
- The header cell checkbox is checked automatically.
Workaround:
void radGridView_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
if (e.CellType == typeof(GridCheckBoxHeaderCellElement))
{
e.CellElement = new GridCheckBoxHeaderCellElement(e.Column,e.Row);
((GridCheckBoxHeaderCellElement)e.CellElement).CheckBox.ToggleStateChanging += CheckBox_ToggleStateChanging;
}
}
void CheckBox_ToggleStateChanging(object sender, StateChangingEventArgs args)
{
if (radDevices.ChildRows.Count == 0)
{
args.Cancel = true;
}
}
To reproduce:
public Form1()
{
InitializeComponent();
GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn("DecimalColumn");
decimalColumn.FormatString = "{0:N0}";
decimalColumn.FieldName = "Price";
radGridView1.MasterTemplate.Columns.Add(decimalColumn);
GridViewCommandColumn commandColumn = new GridViewCommandColumn("CommandColumn");
commandColumn.FormatString = "{0:N0}";
commandColumn.FieldName = "Price";
radGridView1.MasterTemplate.Columns.Add(commandColumn);
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.SaveLayout(@"..\..\..\layout.xml");
this.radGridView1.LoadLayout(@"..\..\..\layout.xml");
FillData();
}
private void FillData()
{
List<Item> items = new List<Item>();
for (int i = 0; i < 5; i++)
{
items.Add(new Item(i * 2.35m));
}
radGridView1.DataSource = items;
}
public class Item
{
public decimal Price { get; set; }
public Item(decimal price)
{
this.Price = price;
}
}
Workaround: use the CellFormatting event and format the GridCommandCellElement.CommandButton.Text property:
private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.Column is GridViewCommandColumn && e.CellElement.Value != null)
{
GridCommandCellElement commandCell = e.CellElement as GridCommandCellElement;
commandCell.CommandButton.Text = string.Format("{0:N0}", e.CellElement.Value);
}
}
To reproduce:
- Set the column like this:
GridViewMaskBoxColumn col = new GridViewMaskBoxColumn();
col.Mask = "&&&&&&&&&&";
col.MaskType = MaskType.Standard;
col.FieldName = "Name";
col.TextMaskFormat = MaskFormat.IncludeLiterals;
- Type two words and press enter.
Workaround:
public class MyRadMaskedEditBoxEditor : RadMaskedEditBoxEditor
{
public override object Value
{
get
{
if (this.MaskTextBox.Mask == "my mask")
{
return this.MaskTextBox.Value;
}
return base.Value;
}
set
{
base.Value = value;
}
}
}
To reproduce: - Open the Search Row sample in the demo application. - Type some text in the search textbox. - Using the context menu of the search textbox add some unicode control characters.
To reproduce, use the following code and afterwards check the CurrentRow.Index property:
this.grid.BeginUpdate();
GridViewDataRowInfo newRow = new GridViewDataRowInfo(grid.MasterView);
this.grid.Rows.Add(newRow);
this.grid.EndUpdate();
Workaround:
radGridView1.Rows.IndexOf(radGridView1.CurrentRow);