To reproduce:
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
BindGrid()
End Sub
Private Sub BindGrid()
Dim r As New Random()
Dim table As New DataTable()
table.Columns.Add("ID", GetType(Integer))
table.Columns.Add("Name", GetType(String))
table.Columns.Add("Bool", GetType(Boolean))
For i As Integer = 0 To 39
table.Rows.Add(i, "Row " & i, If(r.[Next](10) > 5, True, False))
Next
Me.RadGridView1.DataSource = table
End Sub
Dim saveName As Integer
Private Sub RadGridView1_CellEndEdit(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles RadGridView1.CellEndEdit
If e.Column.Name = "Name" Then
saveName = RadGridView1.CurrentRow.Cells("ID").Value
BindGrid()
End If
End Sub
Private Sub RadGridView1_DataBindingComplete(sender As Object, e As Telerik.WinControls.UI.GridViewBindingCompleteEventArgs) Handles RadGridView1.DataBindingComplete
For Each row As GridViewRowInfo In RadGridView1.Rows
If row.Cells("ID").Value = saveName Then
row.IsCurrent = True
RadGridView1.TableElement.EnsureRowVisible(row)
Exit For
End If
Next
End Sub
WORKAROUND:
Rebind the grid in the CellValueChanged event instead of the CellEndEdit event:
Private Sub RadGridView1_CellValueChanged(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles RadGridView1.CellValueChanged
If e.Column.Name = "Name" Then
saveName = RadGridView1.CurrentRow.Cells("ID").Value
BindGrid()
End If
End Sub
Currently one cannot set the column chooser items properties permanently since they are recreated every time the chooser is shown or item is added/removed. Resolution: You can subscribe to the ColumnChooserItemElementCreating event and edit the column chooser items.
By design the MinHeight property is not respected in ColumnGroupsViewDefinition.
The right way to apply MinHeight in the ColumnGroupsViewDefinition is setting the GridViewColumnGroup's RowSpanProperty and GridViewColumnGroupRow's MinHeight property. For example:
this.columnGroupsView = new ColumnGroupsViewDefinition();
this.columnGroupsView.ColumnGroups.Add(new GridViewColumnGroup("General") { RowSpan = 40 });
this.columnGroupsView.ColumnGroups.Add(new GridViewColumnGroup("Details") { RowSpan = 40 });
this.columnGroupsView.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Address") { RowSpan = 40 });
this.columnGroupsView.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Ime Tam") { RowSpan = 40 });
this.columnGroupsView.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow() { MinHeight = 40 });
this.columnGroupsView.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow() { MinHeight = 40 });
this.radGridView1.Columns["ContactName"].RowSpan = 40;
this.columnGroupsView.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["CustomerID"]);
this.columnGroupsView.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ContactName"]);
this.columnGroupsView.ColumnGroups[0].Rows[1].Columns.Add(this.radGridView1.Columns["CompanyName"]);
this.columnGroupsView.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow() { MinHeight = 40 });
this.columnGroupsView.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["City"]);
this.columnGroupsView.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Country"]);
this.columnGroupsView.ColumnGroups[1].Groups[1].Rows.Add(new GridViewColumnGroupRow() { MinHeight = 40 });
this.columnGroupsView.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Phone"]);
When RadGridView is in right to left mode and the data is grouped, the layout of the items that represent the group field names is incorrect - the close button overlays the text.
WORKAROUND:
public Form83()
{
new RadControlSpyForm().Show();
InitializeComponent();
this.radGridView1.GroupByChanged += radGridView1_GroupByChanged;
}
void radGridView1_GroupByChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
{
foreach (GroupFieldElement fieldElement in this.radGridView1.GridViewElement.GroupPanelElement.GetDescendants(
delegate(RadElement element) { return element is GroupFieldElement; }, Telerik.WinControls.TreeTraversalMode.BreadthFirst))
{
fieldElement.TextAlignment = ContentAlignment.MiddleRight;
}
}
Steps at design time:
1.Add a RadGridView to the from and change its Dock property to Fill.
2.Change its AutoSizeColumnsMode property to Fill.
3.Chage the Form.Size property to Width = 527 and Height = 346.
Use the following code:
public Form1()
{
InitializeComponent();
DataTable dt = new DataTable("Items");
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Description", typeof(string));
dt.Columns.Add("Price", typeof(decimal));
dt.Columns.Add("Supplier", typeof(string));
for (int i = 0; i < 10; i++)
{
dt.Rows.Add(i, "Description" + i, i * 0.25, "Supplier" + i);
}
radGridView1.DataSource = dt;
}
Workaround: set the AutoSizeColumnsMode property to Fill in the Form.Load event:
private void Form1_Load(object sender, EventArgs e)
{
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
}
To reproduce:
public Form1()
{
InitializeComponent();
radGridView1.ToolTipTextNeeded += radGridView1_ToolTipTextNeeded;
}
private void radGridView1_ToolTipTextNeeded(object sender, ToolTipTextNeededEventArgs e)
{
GridDataCellElement cell = sender as GridDataCellElement;
if (cell != null)
{
e.ToolTipText = cell.Value.ToString();
toolTipText = e.ToolTipText;
e.ToolTip.OwnerDraw = true;
e.ToolTip.Draw += ToolTip_Draw;
e.ToolTip.Popup += ToolTip_Popup;
}
}
private void ToolTip_Popup(object sender, PopupEventArgs e)
{
e.ToolTipSize = TextRenderer.MeasureText(toolTipText + " ", newFont);
}
Font newFont = new Font("Arial", 15f, FontStyle.Bold);
string toolTipText = string.Empty;
private void ToolTip_Draw(object sender, DrawToolTipEventArgs e)
{
e.Graphics.FillRectangle(SystemBrushes.Control, e.Bounds);
e.DrawBorder();
using (StringFormat sf = new StringFormat())
{
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Far;
sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None;
sf.FormatFlags = StringFormatFlags.NoClip;
e.Graphics.DrawString(e.ToolTipText, newFont, Brushes.Red, e.Bounds, sf);
}
}
If one sets AutoSizeRows to true and AllowSearchRow to true the layout of RadGridView throws an exception.
To reproduce:
Create a form and add a timer with interval of 1 second and in tick handler do the following:
void t_Tick(object sender, EventArgs e)
{
if (this.Controls.Count > 0)
{
Control oldGrid = this.Controls[0];
this.Controls.RemoveAt(0);
oldGrid.Dispose();
GC.Collect(3, GCCollectionMode.Forced);
}
RadGridView grid = new RadGridView();
grid.Dock = DockStyle.Fill;
this.Controls.Add(grid);
}
You will see that the memory consumption will grow.
Workaround:
Use the following custom RadGridView
public class MyRadGridView : RadGridView
{
protected override RadGridViewElement CreateGridViewElement()
{
return new MyElement();
}
}
public class MyElement : RadGridViewElement
{
protected override PagingPanelElement CreatePagingPanelElement()
{
return new MyPagingPanel();
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(RadGridViewElement);
}
}
}
public class MyPagingPanel : PagingPanelElement
{
protected override void CreateButtonsStripElementChildElements()
{
base.CreateButtonsStripElementChildElements();
this.ButtonsStripElement.Children.Add(this.ButtonsStripElement.Grip);
this.ButtonsStripElement.Children.Add(this.ButtonsStripElement.OverflowButton);
this.ButtonsStripElement.Grip.Visibility = this.ButtonsStripElement.OverflowButton.Visibility = ElementVisibility.Collapsed;
}
protected override void CreateTextBoxStripElementChildElements()
{
base.CreateTextBoxStripElementChildElements();
this.TextBoxStripElement.Children.Add(this.TextBoxStripElement.Grip);
this.TextBoxStripElement.Children.Add(this.TextBoxStripElement.OverflowButton);
this.TextBoxStripElement.Grip.Visibility = this.TextBoxStripElement.OverflowButton.Visibility = ElementVisibility.Collapsed;
}
}
Workaround:
void radGridView1_PrintCellFormatting(object sender, PrintCellFormattingEventArgs e)
{
if (e.Column is GridViewImageColumn && e.Row is GridViewDataRowInfo)
{
e.PrintCell.DrawFill = true;
if (radGridView1.PrintStyle.PrintAlternatingRowColor && e.Row.Index % 2 == 1)
{
e.PrintCell.BackColor = radGridView1.PrintStyle.AlternatingRowColor;
}
else
{
e.PrintCell.BackColor = radGridView1.PrintStyle.CellBackColor;
}
}
}
To reproduce: -Add GridViewMaskBoxColumn to a grid. -Set the Mask type to Regex and set any mask you want. -When you leave the cell NullRefernceException is thrown.
To reproduce: - Add GridViewComboBoxColumn to a grid. - Set the DisplayMemeber property like this: column1.DisplayMember = "AddInfo.Status";
DECLINED: this happens only when the double click is outside the bounds of the scroll button which is the expected behavior.
To reproduce: When the user clicks too fast on the quite thin area between the grid's scroll-bar arrow button and the row, it fires the CurrentRowChanging event.
Workaround:
private bool cancelChanging = false;
private void radGridView1_CurrentRowChanging(object sender, CurrentRowChangingEventArgs e)
{
if (cancelChanging)
{
e.Cancel = true;
cancelChanging = false;
}
}
private void radGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
cancelChanging = false;
RadElement element = this.radGridView1.Behavior.GetHoveredRadElement();
while (element != null)
{
if (element.GetType() == typeof(RadScrollBarElement))
{
cancelChanging = true;
break;
}
element = element.Parent;
}
}
Setting the DataSource is slower (about 1/3 times more) when ShowColumnHeaders is set to true. Workaround: Set the ShowColumnHeaders to false, then set the DataSource and restore the ShowColumnHeaders state: radGridView1.ShowColumnHeaders = false; radGridView1.DataSource = mySource; radGridView1.ShowColumnHeaders = true;
This issue appears when one clears the relations collection of RadGridView, it appears sporadically and in rare cases
Extend the cell elements with a button(s) (via decorator for example) which will be visible without putting the grid in edit mode. The buttons should not be visible by default and their visibility will be controlled via property of the column. These buttons can be RadButtonElements which will not hurt the performance. Their purpose will be to inform the end user that some cell is a combo or a date time cell without having to open its editor in advance. When the button is clicked, the corresponding action should be executed e.g. for combo cell, open the editor and show the popup; for spin cell open the editor and perform the click of the desired button. Same goes for the rest of the editors - mccb, color, browse, date time, etc.
Workaround:
Me.RadGridView1.Columns("ProductName").TextAlignment = ContentAlignment.MiddleRight
FIX. RadGridView - cannot show tooltips in GridViewComboBoxColumn, while in RadDropDownList the tooltips work correctly
If you dispose the grid or the form it is placed on the grid's DoubleClick, MouseDoubleClick, MouseDown, etc. events, an exception is thrown.