To reproduce:
public RadForm1()
{
InitializeComponent();
DataTable master = new DataTable();
master.Columns.Add("ID", typeof(int));
master.Columns.Add("test", typeof(string));
for (int i = 0; i < 500; i++)
{
master.Rows.Add(i, "Row " + i);
}
radGridView1.DataSource = master;
radLabel1.Text = "RadGridView: AutoSizeRows = " + ((radGridView1.AutoSizeRows) ? "True" : "False");
}
private void radButton1_Click(object sender, EventArgs e)
{
radGridView1.TableElement.ScrollToRow(radGridView1.MasterTemplate.Rows[200]);
}
private void radButton2_Click(object sender, EventArgs e)
{
radGridView1.AutoSizeRows = !radGridView1.AutoSizeRows;
radLabel1.Text = "RadGridView: AutoSizeRows = " + ((radGridView1.AutoSizeRows) ? "True" : "False");
}
Workaround:
this.radGridView1.ViewDefinition = new CustomTableViewDefinition();
public class CustomTableViewDefinition : TableViewDefinition
{
public override IRowView CreateViewUIElement(GridViewInfo viewInfo)
{
return new CustomGridTableElement();
}
}
public class CustomGridTableElement : GridTableElement
{
protected override Type ThemeEffectiveType
{
get
{
return typeof(GridTableElement);
}
}
public override void ScrollToRow(GridViewRowInfo rowInfo)
{
if (rowInfo == null || rowInfo.IsPinned || !rowInfo.IsVisible || rowInfo is GridViewDetailsRowInfo)
{
return;
}
this.ViewElement.InvalidateMeasure();
this.ViewElement.UpdateLayout();
if (GridViewElement.AutoSizeRows || (ViewTemplate.Templates.Count > 0 && rowInfo.ViewTemplate.Parent != null))
{
ScrollToRowCore(rowInfo, false);
return;
}
this.RowScroller.ScrollToItem(rowInfo, false);
this.UpdateLayout();
}
private void ScrollToRowCore(GridViewRowInfo rowInfo, bool ensureVisible)
{
if (!this.GridViewElement.UseScrollbarsInHierarchy && this.ViewInfo.ParentRow != null)
{
if (ensureVisible)
{
this.GridViewElement.TableElement.EnsureRowVisible(rowInfo);
}
else
{
this.GridViewElement.TableElement.ScrollToRow(rowInfo);
}
return;
}
if (!this.IsInValidState(true) || this.VScrollBar.LargeChange == 0)
{
return;
}
RadControl control = this.ElementTree.Control as RadControl;
if (control != null)
{
control.SuspendUpdate();
}
int oldValue = this.VScrollBar.Value;
GridRowElement rowElement = GetChildRowElement(rowInfo);
if (rowElement == null && this.PageViewMode == PageViewMode.ExplorerBar)
{
if (control != null)
{
control.ResumeUpdate();
}
return;
}
while (this.VScrollBar.Value < this.VScrollBar.Maximum)
{
if (rowElement == null)
{
rowElement = GetChildRowElement(rowInfo);
}
if (rowElement != null)
{
ScrollToPartiallyVisibleRow(rowElement, ensureVisible);
break;
}
else
{
bool scrollRangeChanged = SetScrollValue(this.VScrollBar, this.VScrollBar.Value + this.VScrollBar.SmallChange);
if (this.VScrollBar.Value >= this.VScrollBar.Maximum - this.VScrollBar.LargeChange + 1 && !scrollRangeChanged)
{
SetScrollValue(this.VScrollBar, oldValue);
break;
}
}
}
if (oldValue == this.VScrollBar.Minimum || rowElement != null)
{
if (control != null)
{
control.ResumeUpdate();
}
return;
}
SetScrollValue(this.VScrollBar, 0);
while (this.VScrollBar.Value < oldValue)
{
if (rowElement == null)
{
rowElement = GetChildRowElement(rowInfo);
}
if (rowElement != null)
{
ScrollToPartiallyVisibleRow(rowElement, ensureVisible);
break;
}
else
{
bool scrollRangeChanged = SetScrollValue(this.VScrollBar, this.VScrollBar.Value + this.VScrollBar.SmallChange);
if (this.VScrollBar.Value >= this.VScrollBar.Maximum - this.VScrollBar.LargeChange + 1 && !scrollRangeChanged)
{
SetScrollValue(this.VScrollBar, oldValue);
break;
}
}
}
if (control != null)
{
control.ResumeUpdate();
}
}
private GridRowElement GetChildRowElement(GridViewRowInfo rowInfo)
{
if (rowInfo.ViewInfo == this.ViewInfo)
{
return GetRowElement(rowInfo);
}
else
{
GridTableElement tableElement = GridViewElement.GetRowView(rowInfo.ViewInfo) as GridTableElement;
if (tableElement != null)
{
return tableElement.GetRowElement(rowInfo);
}
}
return null;
}
private void ScrollToPartiallyVisibleRow(GridRowElement rowElement, bool ensureVisible)
{
int delta = 0;
while ((rowElement.ControlBoundingRectangle.Y < ViewElement.ScrollableRows.ControlBoundingRectangle.Y &&
rowElement.ControlBoundingRectangle.Bottom > ViewElement.ScrollableRows.ControlBoundingRectangle.Y) ||
(rowElement.ControlBoundingRectangle.Y < ViewElement.ScrollableRows.ControlBoundingRectangle.Bottom &&
rowElement.ControlBoundingRectangle.Bottom > ViewElement.ScrollableRows.ControlBoundingRectangle.Bottom))
{
if (rowElement.ControlBoundingRectangle.Y < ViewElement.ScrollableRows.ControlBoundingRectangle.Y &&
rowElement.ControlBoundingRectangle.Bottom > ViewElement.ScrollableRows.ControlBoundingRectangle.Y)
{
delta = ViewElement.ScrollableRows.ControlBoundingRectangle.Y - rowElement.ControlBoundingRectangle.Y;
SetScrollValue(this.VScrollBar, this.VScrollBar.Value - delta);
return;
}
if (rowElement.ControlBoundingRectangle.Y < ViewElement.ScrollableRows.ControlBoundingRectangle.Bottom &&
rowElement.ControlBoundingRectangle.Bottom > ViewElement.ScrollableRows.ControlBoundingRectangle.Bottom)
{
delta = rowElement.ControlBoundingRectangle.Top - ViewElement.ScrollableRows.ControlBoundingRectangle.Top;
SetScrollValue(this.VScrollBar, this.VScrollBar.Value + delta);
return;
}
if (ensureVisible)
{
delta = rowElement.ControlBoundingRectangle.Bottom - ViewElement.ScrollableRows.ControlBoundingRectangle.Bottom;
if (delta < 0)
{
break;
}
}
else
{
delta = rowElement.ControlBoundingRectangle.Y - ViewElement.ScrollableRows.ControlBoundingRectangle.Y;
if (delta < 0)
{
delta = 0;
}
}
bool scrollRangeChanged = SetScrollValue(this.VScrollBar, this.VScrollBar.Value + delta);
if (this.VScrollBar.Value >= this.VScrollBar.Maximum - this.VScrollBar.LargeChange + 1 || !scrollRangeChanged)
{
break;
}
}
}
private bool SetScrollValue(RadScrollBarElement scrollbar, int newValue)
{
int max = this.VScrollBar.Maximum;
if (newValue > scrollbar.Maximum - scrollbar.LargeChange + 1)
{
newValue = scrollbar.Maximum - scrollbar.LargeChange + 1;
}
if (newValue < scrollbar.Minimum)
{
newValue = scrollbar.Minimum;
}
scrollbar.Value = newValue;
this.UpdateLayout();
return max != this.VScrollBar.Maximum;
}
}
Introduce a property to change symbol used to separate summaryItems in SummaryRowGroupHeaders.
To reproduce: - Bind the grid to progress binding source at design time. - Locate GroupDescriptors in Properties and click the ellipsis button to open the GroupDescriptor Collection Editor. - Click Add and select the new item. - Select the GroupNames collection to open the SortDescriptor Collection Editor. - Click Add. - An exception is thrown and the UI freezes. Workaround: Add descriptors at runime.
To reproduce: - Assing context menu using one of the default properties.
To reproduce:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products)
Me.CategoriesTableAdapter.Fill(Me.NwindDataSet.Categories)
Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products)
Me.CategoriesTableAdapter.Fill(Me.NwindDataSet.Categories)
RadGridView1.AutoGenerateHierarchy = True
RadGridView1.DataSource = Me.NwindDataSet
RadGridView1.DataMember = "Categories"
End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Dim style As New GridPrintStyle()
style.PrintHierarchy = True
style.HierarchyIndent = 20
style.ChildViewPrintMode = ChildViewPrintMode.SelectViewToPrint
Me.RadGridView1.PrintStyle = style
Me.RadGridView1.PrintPreview()
End Sub
Please refer to the attached gif file.
Workaround:
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Me.RadGridView1.PrintSettingsDialogFactory = New CustomGridViewPrintSettingsDialogFactory()
Dim style As New GridPrintStyle()
style.PrintHierarchy = True
style.HierarchyIndent = 20
style.ChildViewPrintMode = ChildViewPrintMode.SelectViewToPrint
Me.RadGridView1.PrintStyle = style
Me.RadGridView1.PrintPreview()
End Sub
Public Class CustomGridViewPrintSettingsDialog
Inherits GridViewPrintSettingsDialog
Sub New(document As RadPrintDocument)
MyBase.New(document)
End Sub
Protected Overrides Sub LoadSettings()
MyBase.LoadSettings()
Dim gridView As RadGridView = TryCast(Me.PrintDocument.AssociatedObject, RadGridView)
Me.printStyleSettingControl.PrintStyle.PrintHierarchy =gridView.PrintStyle.PrintHierarchy
End Sub
End Class
Public Class CustomGridViewPrintSettingsDialogFactory
Implements IPrintSettingsDialogFactory
Public Function CreateDialog(document As RadPrintDocument) As Form Implements IPrintSettingsDialogFactory.CreateDialog
Return New CustomGridViewPrintSettingsDialog(document)
End Function
End Class
To reproduce:
public Form1()
{
InitializeComponent();
this.radGridView1.Columns.Add("Name");
this.radGridView1.Columns.Add("ID");
this.radGridView1.RowsChanged += radGridView1_RowsChanged;
}
private void radGridView1_RowsChanged(object sender, GridViewCollectionChangedEventArgs e)
{
Console.WriteLine(e.Action);
if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Add)
{
GridViewRowInfo row = e.NewItems[0] as GridViewRowInfo;
row.Cells["ID"].Value = this.radGridView1.Rows.Count;
}
}
private void radButton1_Click(object sender, EventArgs e)
{
this.radGridView1.Rows.Add("Item" + this.radGridView1.Rows.Count);
}
Note: the first firing of the RowsChanged event used to be with Action=Add.
Please refer to the attached sample project.
Workaround: change the name of the column this.radGridView1.Columns["Table:Name"].Name = "Table|Name";
When you set a RadGridView's SelectionMode to GridViewSelectionMode.CellSelect and then you highlight full rows by using the row header, the SelectedRows collection is empty. Telerik support informed me this is "as expected" and that I should use "SelectedCells" collection when using the CellSelect Mode. While this is a decent workaround I don't see why SelectedRows collection can't be filled when the entire row is actually highlighted.
Create a DataTable with columns Column1, Column2, Column3, Column4, Column5, and bound to RadGridView. Create a second DataTable with columns Column1, Column2a, Column3, Column4, Column5, and re-bind the RadGridView to this DataTable. Instead of the columns appearing in the same order as they are in the second DataTable, they show up as Column1, Column3, Column4, Column5, Column2a in the RadGridView.
To reproduce:
GridViewImageColumn imageColumn = new GridViewImageColumn();
imageColumn.Name = "ImageColumn";
imageColumn.FieldName = "ImageColumn";
imageColumn.HeaderText = "Picture";
radGridView1.MasterTemplate.Columns.Add(imageColumn);
List<classBinding> databinding = new List<classBinding>();
for (int i = 0; i < 35000; i++)
{
databinding.Add(new classBinding()
{
ImageColumn = Properties.Resources.Alarm2,
});
}
radGridView1.DataSource = databinding;
public class classBinding
{
public System.Drawing.Bitmap ImageColumn { get; set; }
}
There should be a convenient and more straightforward API for accessing the TableElement of a child gridview. Currently, the API is:
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement is GridDetailViewCellElement)
{
((GridDetailViewCellElement)e.CellElement).ChildTableElement.RowHeight = 50;
}
}
Steps to reproduce: - create a winforms project - create form (normal windows form, not telerik form) - create radgridview from toolbox - right click and open property builder - select mastertemplate - set viewdefinition = columngroups view - add 3-4 columns (textbox, combobox, etc...) - click ok button at the property builder - right click on the radgridview and open the property builder - rename the name and the header text of the first column - click ok button at the property builder
To reproduce:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CategoriesTableAdapter.Fill(Me.NwindDataSet.Categories)
Me.RadGridView1.DataSource = Me.CategoriesBindingSource
Dim viewDef As New ColumnGroupsViewDefinition
Dim group1 = New GridViewColumnGroup()
Dim row1 = New GridViewColumnGroupRow
group1.Rows.Add(row1)
row1.ColumnNames.Add("CategoryID")
row1.ColumnNames.Add("CategoryName")
viewDef.ColumnGroups.Add(group1)
Dim group2 = New GridViewColumnGroup()
Dim row2 = New GridViewColumnGroupRow
group2.Rows.Add(row2)
row2.ColumnNames.Add("Description")
row2.ColumnNames.Add("Picture")
viewDef.ColumnGroups.Add(group2)
Me.RadGridView1.ViewDefinition = viewDef
End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Console.WriteLine("BEFORE >>")
For Each col As GridViewColumn In Me.RadGridView1.Columns
Console.WriteLine(col.Name & " >> " & col.Width )
Next
Dim style As New GridPrintStyle()
style.FitWidthMode = PrintFitWidthMode.FitPageWidth
Me.RadGridView1.PrintStyle = style
Me.RadGridView1.PrintPreview()
Console.WriteLine("AFTER >>")
For Each col As GridViewColumn In Me.RadGridView1.Columns
Console.WriteLine(col.Name & " >> " & col.Width)
Next
End Sub
IMPORTANT: If you resize one of the columns at run time before calling the PrintPreview method, the columns' width is restored. In addition, if you call the PrintPreview method without resizing the columns before that, close the dialog and hide one of the columns by using the default context menu, the columns' width for the visible columns is enlarged.
Workaround: you can get the columns width by using the ColumnGroupRowLayout:
Dim rowLayout As ColumnGroupRowLayout = TryCast(Me.RadGridView1.TableElement.ViewElement.RowLayout, ColumnGroupRowLayout)
For Each col As GridViewColumn In Me.RadGridView1.Columns
Dim info As ColumnGroupsCellArrangeInfo = rowLayout.GetColumnData(col)
Debug.WriteLine(col.Name & " >> " & info.Bounds.Width)
Next
To reproduce:
- Add DateTime column and set the RowHeight to 20.
- Set the theme to Windows7.
- The text is not visible when the editor is shown.
Workaround:
private void RadGridView2_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
RadDateTimeEditor editor = e.ActiveEditor as RadDateTimeEditor;
if (editor != null)
{
var element = editor.EditorElement as RadDateTimeEditorElement;
element.Font = new Font("Segoe UI", 8, FontStyle.Regular);
element.Children[1].Visibility = ElementVisibility.Collapsed;
element.TextBoxElement.ShowBorder = false;
element.TextBoxElement.TextBoxItem.HostedControl.MinimumSize = new Size(0, 12);
}
}
To reproduce: please refer to the attached sample project.
1. Edit the CommonInt property for the first child row.
2. Edit the CommonInt property for the second child row.
Workaround: Add the grid programmatically at run time.
Second Workaround:
this.radGridView1.CellValueChanged+=radGridView1_CellValueChanged;
private void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e)
{
e.Column.OwnerTemplate.Refresh(e.Column);
}
How to reproduce:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.radGridView1.DataSource = this.GetSampleData();
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.EnableFiltering = true;
this.radGridView1.ShowFilteringRow = false;
this.radGridView1.ShowHeaderCellButtons = true;
}
private DataTable GetSampleData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(double));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("IsValid", typeof(bool));
dt.Columns.Add("Date", typeof(DateTime));
for (int i = 0; i < 115; i++)
{
dt.Rows.Add(((double)i * 5 / 7) * 3, "Name " + i, i % 2 == 0, DateTime.Now.AddDays(i));
}
return dt;
}
}
Workaround specify decimal as the type of the column in the DataTable object or clone the DataTAble object and change the type of the column:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
DataTable dt = this.GetSampleData();
DataTable dtCloned = dt.Clone();
dtCloned.Columns[0].DataType = typeof(decimal);
foreach (DataRow row in dt.Rows)
{
dtCloned.ImportRow(row);
}
this.radGridView1.DataSource = dtCloned;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.EnableFiltering = true;
this.radGridView1.ShowFilteringRow = false;
this.radGridView1.ShowHeaderCellButtons = true;
}
private DataTable GetSampleData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(double));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("IsValid", typeof(bool));
dt.Columns.Add("Date", typeof(DateTime));
for (int i = 0; i < 115; i++)
{
dt.Rows.Add(((double)i * 5 / 7) * 3, "Name " + i, i % 2 == 0, DateTime.Now.AddDays(i));
}
return dt;
}
}
To reproduce:
private void Form1_Load(object sender, EventArgs e)
{
this.productsTableAdapter.Fill(this.nwindDataSet.Products);
this.categoriesTableAdapter.Fill(this.nwindDataSet.Categories);
this.radGridView1.DataSource = this.productsBindingSource;
GridViewMultiComboBoxColumn col = new GridViewMultiComboBoxColumn();
col.DataSource = this.categoriesBindingSource;
col.MinWidth = 200;
col.DisplayMember = "CategoryName";
col.ValueMember = "CategoryID";
this.radGridView1.Columns.Add(col);
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.CellValueChanged += radGridView1_CellValueChanged;
}
private void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e)
{
RadMessageBox.Show("CellValueChanged. Value >> " + e.Value.ToString());
}
Selected rows/cells of RadGridView should not be exporting with their selected visual styles and this is why when the export starts all selected rows are cleared. At the end of export selection is restored. This is the reason Validating/ed and SelectionChanged events are fired when exporting with RadGridView exports. Workaround: Unsubscribe from these events before the export starts and subscribe to them again when export operation is completed. this.radGridView1.RowValidating -= radGridView1_RowValidating; this.radGridView1.SelectionChanged -= radGridView1_SelectionChanged; // Export ExportToExcelML excelMLExporter = new ExportToExcelML(this.radGridView1); excelMLExporter.ExportVisualSettings = true; excelMLExporter.RunExport(fileName); this.radGridView1.RowValidating += radGridView1_RowValidating; this.radGridView1.SelectionChanged += radGridView1_SelectionChanged;