Workaround:
AddHandler Me.RadGridView1.CreateCompositeFilterDialog, AddressOf CreateCompositeFilterDialog
Private Sub CreateCompositeFilterDialog(sender As Object, e As GridViewCreateCompositeFilterDialogEventArgs)
Dim dialog As New CompositeDataFilterForm()
AddHandler dialog.DataFilter.EditorRequired, AddressOf EditorRequired
e.Dialog = dialog
End Sub
Private Sub EditorRequired(sender As Object, e As TreeNodeEditorRequiredEventArgs)
Dim filterNode As DataFilterCriteriaNode = TryCast(e.Node, DataFilterCriteriaNode)
If filterNode IsNot Nothing AndAlso filterNode.PropertyName = "BASE_NULL_DATE" AndAlso TypeOf sender Is DataFilterValueEditorElement Then
e.Editor = New TreeViewDateTimeEditor()
End If
End Sub
To reproduce: please refer to the attached sample project and follow the described steps in the .doc file located in the zip.
Workaround:
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
this.ActiveControl = this.gvDetails;
}
private void gvDetails_LostFocus(object sender, EventArgs e)
{
((ComponentBehavior)gvDetails.Behavior).GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Instance);
PropertyInfo barProperty = ((ComponentBehavior)gvDetails.Behavior).GetType().GetProperty("ScreenPresenter",
BindingFlags.NonPublic | BindingFlags.Instance);
Form screenTip = barProperty.GetValue(((ComponentBehavior)gvDetails.Behavior), null) as Form;
screenTip.Hide();
}
To reproduce: please open the attached sample project and follow the steps illustrated in the attached gif file.
Workaround:
1. You still can scroll while dragging a row by using the mouse wheel.
2. Use the grid in unbound mode and set the AllowRowReorder property to true instead of using a custom RadDragDropService.
3. Use a custom drag and drop service:
public class CustomDragDropService : RadGridViewDragDropService
{
public CustomDragDropService(RadGridViewElement gridViewElement) : base(gridViewElement)
{
}
public override string Name
{
get
{
return typeof(RadGridViewDragDropService).Name;
}
}
protected override void HandleMouseMove(System.Drawing.Point mousePosition)
{
base.HandleMouseMove(mousePosition);
System.Drawing.Point location = this.GridViewElement.ElementTree.Control.PointToClient(Control.MousePosition);
GridTableElement tableElement = this.GetTableElementAtPoint(location);
ISupportDrag supportDrag = this.Context as ISupportDrag;
object dataContext = supportDrag.GetDataContext();
if (this.AllowAutoScrollRowsWhileDragging && dataContext == null)
{
ScrollRows(tableElement, location);
}
}
private void ScrollRows(GridTableElement tableElement, System.Drawing.Point location)
{
ScrollableRowsContainerElement scrollableRows = tableElement.ViewElement.ScrollableRows;
RadScrollBarElement vScrollbar = GetVeritcalScrollbar(tableElement);
System.Drawing.Rectangle containerBounds = scrollableRows.ControlBoundingRectangle;
if (containerBounds.Contains(location) ||
location.X < containerBounds.X ||
location.X > containerBounds.Right)
{
return;
}
int delta = 0;
if (location.Y > containerBounds.Bottom)
{
delta = location.Y - containerBounds.Bottom;
}
else if (location.Y < containerBounds.Y)
{
delta = location.Y - containerBounds.Y;
}
if (delta != 0 && vScrollbar.Visibility == ElementVisibility.Visible)
{
vScrollbar.Value = ClampValue(vScrollbar.Value + delta,
vScrollbar.Minimum,
vScrollbar.Maximum - vScrollbar.LargeChange + 1);
}
}
private int ClampValue(int value, int minimum, int maximum)
{
if (value < minimum)
{
return minimum;
}
if (maximum > 0 && value > maximum)
{
return maximum;
}
return value;
}
private RadScrollBarElement GetVeritcalScrollbar(GridTableElement tableElement)
{
if (GridViewElement.UseScrollbarsInHierarchy)
{
return tableElement.VScrollBar;
}
return GridViewElement.TableElement.VScrollBar;
}
}
public RadForm1()
{
InitializeComponent();
CustomDragDropService customService = new CustomDragDropService(radGridView1.GridViewElement);
radGridView1.GridViewElement.RegisterService(customService);
}
To reproduce: please refer to the attached sample project. Note that the CellValidating event is fired twice even without showing a RadMessageBox. With an MS Button the problem is not reproducible.
Workaround: use the RadGridView.ValueChanging event to perform validation while the user is typing in the active editor:
private void radGridView1_ValueChanging(object sender, Telerik.WinControls.UI.ValueChangingEventArgs e)
{
if (((string)e.NewValue) != "x")
{
RadMessageBox.Show("Only 'x' allowed!");
e.Cancel = true;
}
}
To reproduce: please refer to the attached sample project and gif file.
Workaround: use the CellFormatting event and apply the light orange BackColor for the selected cells belonging to the current pinned column:
private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if (e.Row.IsSelected && e.Column.IsCurrent)
{
e.CellElement.BackColor = Color.FromArgb(255, 231, 174);
}
else
{
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
}
}
Use attached project to reproduce!
Another case is when the font size is changed from the settings dialog - in this case, the row height is not adjusted.
Workaround:
Use the following custom print style:
class MyTableViewDefinitionPrintRenderer : TableViewDefinitionPrintRenderer
{
public MyTableViewDefinitionPrintRenderer(RadGridView grid) : base(grid)
{
}
protected override int GetDataRowHeight(GridViewRowInfo row, TableViewRowLayoutBase rowLayout)
{
int result = base.GetDataRowHeight(row, rowLayout);
int newHeight = 0;
if (!(row is GridViewGroupRowInfo))
{
foreach (GridViewColumn col in row.ViewTemplate.Columns)
{
if (col is GridViewRowHeaderColumn || col is GridViewIndentColumn || !col.IsVisible)
{
continue;
}
string value = row.Cells[col.Name].Value.ToString();
TableViewCellArrangeInfo info = ((TableViewRowLayout)rowLayout).LayoutImpl.GetArrangeInfo(col);
float cellWidth = (float)info.CachedWidth;
int currentHeight = TextRenderer.MeasureText(value, this.GridView.PrintStyle.CellFont, new Size((int)cellWidth, 0), TextFormatFlags.WordBreak).Height + this.GridView.Font.Height *4;
newHeight = Math.Max(newHeight, currentHeight);
}
}
return Math.Max(newHeight, result);
}
}
class MyPrintStyle :GridPrintStyle
{
protected override BaseGridPrintRenderer InitializePrintRenderer(RadGridView grid)
{
return new MyTableViewDefinitionPrintRenderer(grid);
}
}
To reproduce:
private void RadGridView1_KeyPress(object sender, KeyPressEventArgs e)
{
int startIndex = radGridView1.CurrentRow.Index +1;
for (int i = startIndex; i < radGridView1.Rows.Count; i++)
{
var value = radGridView1.Rows[i].Cells["Name"].Value.ToString().ToLower();
if (value.StartsWith(e.KeyChar.ToString()))
{
radGridView1.TableElement.ScrollToRow(radGridView1.Rows[i]);
radGridView1.ClearSelection();
radGridView1.Rows[i].IsSelected = true;
radGridView1.Rows[i].IsCurrent = true;
radGridView1.Columns[1].IsCurrent = true;
break;
}
}
}
- Press some key so the grid is scrolled down, then press the down key.
- The first row is selected instead of the next one.
Workaround:
remove this line:
radGridView1.Rows[i].IsSelected = true;
To reproduce: 1. Run the attached sample project. 2. Right-click the grid. 3. Quickly navigate to another application (e.g. Windows Explorer) before the context menu is shown & wait at windows explorer to display the menu 4. The context will be stuck.
To reproduce: run the attached sample project and you will notice that the top border is missing as it is illustrated in the screenshot. Workaround: set the RadGridView.AutoSizeRows property to false.
To reproduce:
public RadForm1()
{
InitializeComponent();
radGridView1.DataSource = GetTable();
GridViewSummaryItem summaryItem = new GridViewSummaryItem();
summaryItem.Name = "Name";
summaryItem.Aggregate = GridAggregateFunction.Count;
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
summaryRowItem.Add(summaryItem);
this.radGridView1.SummaryRowsBottom.Add(summaryRowItem);
radGridView1.ViewCellFormatting += RadGridView1_ViewCellFormatting;
}
private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement is GridSummaryCellElement)
{
e.CellElement.DrawFill = true;
e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
e.CellElement.BackColor = Color.Red;
}
else
{
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, Telerik.WinControls.ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
radGridView1.MasterView.SummaryRows[0].PinPosition = PinnedRowPosition.Bottom;
}
static DataTable GetTable()
{
DataTable table = new DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Columns.Add("Drug", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Date", typeof(DateTime));
for (int i = 0; i < 5; i++)
{
table.Rows.Add(25, "Indocin", "David", DateTime.Now);
table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
}
return table;
}
private void radButton1_Click(object sender, EventArgs e)
{
radGridView1.SaveLayout("test.xml");
}
private void radButton2_Click(object sender, EventArgs e)
{
radGridView1.SummaryRowsBottom.Clear();
radGridView1.SummaryRowsTop.Clear();
radGridView1.LoadLayout("test.xml");
}
To reproduce: this.radGridView1.MultiSelect = true; this.radGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect; radGridView1.ShowRowHeaderColumn = false; Then select the cells in the firs column by dragging the mouse. Workaround: // radGridView1.ShowRowHeaderColumn = false; radGridView1.TableElement.RowHeaderColumnWidth = 0;
Workaround: handle the GridViewPdfExport.CellFormatting event and apply the column`s format string
Public Class Form1
Sub New()
InitializeComponent()
Me.RadGridView1.DataSource = Me.GetData()
Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
Dim decimalColumn = DirectCast(Me.RadGridView1.Columns("Money"), GridViewDecimalColumn)
decimalColumn.DecimalPlaces = 0
decimalColumn.FormatString = "{0:C0}"
Dim dateTimeColumn = DirectCast(Me.RadGridView1.Columns("Date"), GridViewDateTimeColumn)
dateTimeColumn.FormatString = "{0:D}"
End Sub
Private Function GetData() As Object
Dim dataTable As New DataTable()
dataTable.Columns.Add("Id", GetType(Integer))
dataTable.Columns.Add("Name", GetType(String))
dataTable.Columns.Add("Money", GetType(Decimal))
dataTable.Columns.Add("Date", GetType(DateTime))
For i As Integer = 0 To 999
dataTable.Rows.Add(i, "Name " & i, i * 10, DateTime.Now.AddDays(i))
Next
Return dataTable
End Function
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Dim pdfExporter = New GridViewPdfExport(Me.RadGridView1)
AddHandler pdfExporter.CellFormatting, AddressOf pdfExporter_CellFormatting
Dim renderer = New PdfExportRenderer()
Dim fileName As String = "..\..\exported-grid.pdf"
pdfExporter.RunExport(fileName, renderer)
End Sub
Private Sub pdfExporter_CellFormatting(sender As Object, e As PdfExportCellFormattingEventArgs)
If e.RowIndex > -1 Then
e.CellElement.Text = TryCast(RadDataConverter.Instance.Format(e.Row.Cells(e.ColumnIndex).Value, GetType(String), e.Column), String)
End If
End Sub
End Class
How to reproduce:
public partial class Form1 : Form
{
private RadGridView grid = new RadGridView();
public Form1()
{
InitializeComponent();
Controls.Add(grid);
grid.Dock = DockStyle.Fill;
grid.DataSource = this.GetData();
}
private object GetData()
{
DataTable dataTable = new DataTable();
dataTable.Columns.Add("Id", typeof(int));
dataTable.Columns.Add("Name", typeof(string));
dataTable.Columns.Add("Checked", typeof(bool));
for (int i = 0; i < 200; i++)
{
dataTable.Rows.Add(i, "Name " + i, i % 2 == 0);
}
return dataTable;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
GridViewCheckBoxColumn checkBoxColumn = (GridViewCheckBoxColumn)grid.Columns["Checked"];
checkBoxColumn.EnableHeaderCheckBox = true;
checkBoxColumn.SortOrder = RadSortOrder.Ascending;
}
}
Workaround:
public partial class Form1 : Form
{
private RadGridView grid = new RadGridView();
public Form1()
{
InitializeComponent();
Controls.Add(grid);
grid.Dock = DockStyle.Fill;
grid.DataSource = this.GetData();
grid.MouseDown += grid_MouseDown;
grid.MouseUp += grid_MouseUp;
}
private object GetData()
{
DataTable dataTable = new DataTable();
dataTable.Columns.Add("Id", typeof(int));
dataTable.Columns.Add("Name", typeof(string));
dataTable.Columns.Add("Checked", typeof(bool));
for (int i = 0; i < 200; i++)
{
dataTable.Rows.Add(i, "Name " + i, i % 2 == 0);
}
return dataTable;
}
private void grid_MouseDown(object sender, MouseEventArgs e)
{
RadGridView grid = (RadGridView)sender;
RadCheckBoxElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckBoxElement;
if (cell != null && cell.Parent is GridCheckBoxHeaderCellElement)
{
sw = new Stopwatch();
sw.Start();
grid.BeginUpdate();
}
}
Stopwatch sw;
private void grid_MouseUp(object sender, MouseEventArgs e)
{
RadGridView grid = (RadGridView)sender;
RadCheckBoxElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckBoxElement;
if (cell != null && cell.Parent is GridCheckBoxHeaderCellElement)
{
grid.EndUpdate();
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
GridViewCheckBoxColumn checkBoxColumn = (GridViewCheckBoxColumn)grid.Columns["Checked"];
checkBoxColumn.EnableHeaderCheckBox = true;
checkBoxColumn.SortOrder = RadSortOrder.Ascending;
}
}
To reproduce: please refer to the attached sample project and follow the steps in the provided gif file:
1. Enter something in the search bar
2. Filter on some column, uncheck "All", then select a few items, then validate
3. Click on a random row on the grid
4. Filter on the same column as in 2., check "All", then uncheck a few items, then validate
Workaround:
private void radGridView1_FilterChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
{
this.radGridView1.MasterTemplate.Refresh();
}
To reproduce - Start the attached project press "Add in code" then "Save" - The row is still not added to the underlying data table. Workaround: TryCast(Me.radGridView1.Rows.Last().DataBoundItem, IEditableObject).EndEdit()
Please refer to the attached sample project and gif file illustrating the behavior.
ColumnGroupsViewDefinition view = this.radGridView1.ViewDefinition as ColumnGroupsViewDefinition;
foreach (GridViewColumnGroup group in view.ColumnGroups)
{
group.ShowHeader = false;
}
Workaround: use the ViewCellFormatting and enable the back color for the header cells that are over the hidden group headers
public RadForm1()
{
InitializeComponent();
ColumnGroupsViewDefinition view = this.radGridView1.ViewDefinition as ColumnGroupsViewDefinition ;
foreach (GridViewColumnGroup group in view.ColumnGroups)
{
group.ShowHeader = false;
}
}
private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.Row is GridViewTableHeaderRowInfo && !(e.CellElement is GridColumnGroupCellElement))
{
e.CellElement.DrawFill = true;
e.CellElement.BackColor = Color.FromArgb(234, 242, 252);
e.CellElement.GradientStyle = GradientStyles.Solid;
}
else
{
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
}
}
How to reproduce:
public partial class Form1 : Form
{
public class Data
{
public bool Checked { get; set; }
public string Text { get; set; }
}
private readonly RadGridView _grid;
private readonly List<Data> _dataList = new List<Data>
{
new Data {Text = "abc"},
new Data {Text = "def"},
new Data {Text = "ghi"},
new Data {Text = "jkl"},
new Data {Text = "mno"},
new Data {Text = "pqr"},
new Data {Text = "stu"},
new Data {Text = "vwx"},
new Data {Text = "yz0"}
};
public Form1()
{
InitializeComponent();
_grid = new RadGridView
{
Dock = DockStyle.Fill,
AllowSearchRow = true
};
Controls.Add(_grid);
_grid.DataSource = _dataList;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
_grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
((GridViewCheckBoxColumn)_grid.Columns["Checked"]).EnableHeaderCheckBox = true;
_grid.Columns["Checked"].SortOrder = RadSortOrder.Ascending;
((GridViewCheckBoxColumn)_grid.Columns["Checked"]).Checked = ToggleState.On;
_grid.MasterView.TableSearchRow.Search("abc");
}
}
Workaround: clear the search text
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
_grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
((GridViewCheckBoxColumn)_grid.Columns["Checked"]).EnableHeaderCheckBox = true;
_grid.Columns["Checked"].SortOrder = RadSortOrder.Ascending;
((GridViewCheckBoxColumn)_grid.Columns["Checked"]).Checked = ToggleState.On;
_grid.MasterView.TableSearchRow.Search("abc");
this._grid.MouseDown += _grid_MouseDown;
}
private void _grid_MouseDown(object sender, MouseEventArgs e)
{
RadGridView grid = (RadGridView)sender;
RadCheckBoxElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckBoxElement;
if (cell != null && cell.Parent is GridCheckBoxHeaderCellElement && grid.SortDescriptors.Count > 0))
{
grid.MasterView.TableSearchRow.Search("");
}
}
To reproduce: please refer to the attached gif file and sample project.
Workaround: when you set the DrawFill property to true, specify the BackColor to the desired one and reset for the rest of the cells.
private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if (e.Column.Name == "ProductName" && e.Row is GridViewDataRowInfo)
{
if (e.CellElement.Value.ToString().Contains("C"))
{
e.CellElement.DrawFill = true;
e.CellElement.BackColor = Color.Yellow;
e.CellElement.GradientStyle = GradientStyles.Solid;
e.CellElement.ForeColor = Color.OliveDrab;
}
else
{
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
}
}
else
{
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
}
}