After a couple clicks, grid's context menu becomes unresponsive when using RadGridView through remote connection and Windows 7
The events are fired in the following order: UserAddingRow, EditorRequired, UserAddedRow eventfired when the new is pinned at the bottom and TAB key is processed.
Workaround:
public class FixGridNewRowBehavior : GridNewRowBehavior
{
protected override bool ProcessTabKey(System.Windows.Forms.KeyEventArgs keys)
{
bool isInEditMode = this.EditorManager.IsInEditMode;
if (isInEditMode)
{
IGridNavigator navigator = GridViewElement.Navigator;
bool isLeftNavigation = navigator.IsFirstColumn(GridViewElement.CurrentColumn) && keys.Shift;
bool isRightNavigation = navigator.IsLastColumn(GridViewElement.CurrentColumn) && !keys.Shift;
if (isLeftNavigation || isRightNavigation)
{
this.GridViewElement.EndEdit();
}
if (isLeftNavigation)
{
navigator.SelectLastColumn();
}
else if (isRightNavigation)
{
navigator.SelectFirstColumn();
}
if (isLeftNavigation || isRightNavigation)
{
GridViewElement.BeginEdit();
return true;
}
}
return base.ProcessTabKey(keys);
}
}
BaseGridBehavior gridBehavior = this.radGridView1.GridBehavior as BaseGridBehavior;
gridBehavior.UnregisterBehavior(typeof(GridViewNewRowInfo));
gridBehavior.RegisterBehavior(typeof(GridViewNewRowInfo), new FixGridNewRowBehavior());
To reproduce:
Sub New()
InitializeComponent()
Dim dt As New DataTable()
dt.Columns.Add("Name", GetType(String))
dt.Columns.Add("Price", GetType(Decimal))
dt.Columns.Add("Id", GetType(Integer))
dt.Columns.Add("ActivatedOn", GetType(DateTime))
For i As Integer = 0 To 4
dt.Rows.Add("Item" & i, i * 0.25, i, DateTime.Now.AddHours(i))
Next
Me.RadGridView1.DataSource = dt
Me.RadGridView1.Columns("Id").[ReadOnly] = True
Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
AddHandler Me.RadGridView1.DefaultValuesNeeded, AddressOf radGridView1_DefaultValuesNeeded
Me.RadGridView1.NewRowEnterKeyMode = RadGridViewNewRowEnterKeyMode.EnterMovesToLastAddedRow
End Sub
Private Sub radGridView1_DefaultValuesNeeded(sender As Object, e As GridViewRowEventArgs)
e.Row.Cells("Id").Value = Me.radGridView1.Rows.Count
e.Row.Cells("ActivatedOn").Value = DateTime.Now
End Sub
Select the read-only cell inside the new row and press Enter. You will notice that two duplicated rows are added.
Workaround: handle the RadGridView.PreviewKeyDown event and change the current column to one that is not read-only
AddHandler Me.RadGridView1.PreviewKeyDown, AddressOf GridPreviewKeyDown
Private Sub GridPreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs)
If e.KeyCode = Keys.Enter Then
Me.RadGridView1.CurrentColumn = Me.RadGridView1.Columns(0)
Me.RadGridView1.BeginEdit()
End If
End Sub
1. Create a new project with RadGridView and setup 2 level hierarchy.
2. Add a checkbox column at the second level and set its pinned state to Left.
3. Run the application.
4. Expand the first row and click on the checkbox. Be sure that RadGridView contains enough columns in its child view to show horizontal scrollbar.
Workaround: create a custom view definition
public class CustomTableViewDefinition : TableViewDefinition
{
public override IRowView CreateViewUIElement(GridViewInfo viewInfo)
{
CustomTableElement table = new CustomTableElement();
return table;
}
}
public class CustomTableElement : GridTableElement
{
protected override Type ThemeEffectiveType
{
get
{
return typeof(GridTableElement);
}
}
public override bool EnsureCellVisible(GridViewRowInfo rowInfo, GridViewColumn column)
{
if (column.IsPinned)
{
return true;
}
return base.EnsureCellVisible(rowInfo, column);
}
}
Set the view definition to the child template by using the ViewDefinition property
this.gridViewDemoData.Templates[0].ViewDefinition = new CustomTableViewDefinition();
To reproduce:
- Set the first column header text to "+R/S";
- Export the grid with spread export.
Workaround:
class MySpreadExportRenderer : SpreadExportRenderer
{
public override void SetCellSelectionValue(string text)
{
if (text == "+R/S")
{
var cellSelection = typeof(SpreadExportRenderer).GetField("cellSelection", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this) as CellSelection;
CellRange range = cellSelection.CellRanges.ElementAtOrDefault(0);
CellValueFormat cvf = new CellValueFormat("@");
var worksheet = typeof(SpreadExportRenderer).GetField("worksheet", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this) as Worksheet;
worksheet.Cells[range.FromIndex.RowIndex, range.FromIndex.ColumnIndex].SetFormat(cvf);
}
base.SetCellSelectionValue(text);
}
}
Workaround: Use a custom editor and override IsModified method:
class MyEditor : RadDropDownListEditor
{
public override bool IsModified
{
get
{
return true;
}
}
}
void radGridViewFilter_EditorRequired(object sender, EditorRequiredEventArgs e)
{
if (e.EditorType == typeof(RadDropDownListEditor)) { e.Editor = new MyEditor();
}
}
Workaround the issue by using the DataBindingComplete event in the following manner:
private GridViewRowInfo oldCurrentRow = null;
protected override void OnLoad(EventArgs e)
{
this.radGridView1.DataBindingComplete += this.OnDataBindingComplete;
this.oldCurrentRow = this.radGridView1.CurrentRow;
this.radGridView1.DataSource = Telerik.Help.Data.GetDummyEmployees(0);
}
private void OnDataBindingComplete(object sender, Telerik.WinControls.UI.GridViewBindingCompleteEventArgs e)
{
if (this.oldCurrentRow != this.radGridView1.CurrentRow && this.radGridView1.RowCount == 0)
{
this.radGridView1.MasterTemplate.EventDispatcher.RaiseEvent<CurrentRowChangedEventArgs>(EventDispatcher.CurrentRowChanged,
this.radGridView1.MasterTemplate, new CurrentRowChangedEventArgs(null, null));
}
this.oldCurrentRow = null;
}
To reproduce:
- add a grid to the form and use the following code for its setup:
radGridView2.Columns.Add("ID");
radGridView2.Columns.Add("Title");
radGridView2.MultiSelect = true;
radGridView2.Columns[0].SortOrder = RadSortOrder.Ascending;
radGridView2.ReadOnly = true;
radGridView2.BeginUpdate();
for (int i = 0; i < 5; i++)
{
GridViewDataRowInfo row = new GridViewDataRowInfo(radGridView2.MasterTemplate.MasterViewInfo);
row.Cells["ID"].Value = i;
row.Cells["Title"].Value = "Title " + i;
radGridView2.Rows.Add(row);
}
radGridView2.EndUpdate(true);
radGridView2.Rows[0].IsCurrent = true;
radGridView2.Rows[0].IsSelected= true;
- Once the application is started, hold down the shift key and click the third row in the grid
Expected result: the first three rows are selected
Actual result: the last three rows are selected
WORKAROUND:
Use the BeginUpdate and EndUpdate methods of the TableElement, not the control:
radGridView2.TableElement.BeginUpdate();
//add rows
radGridView2.TableElement.EndUpdate(true);
To reproduce: bind the grid to self reference data source, and on a button click, Fill the TableAdapter
Workaround: clear the relations to clear the cache and add them back after the adapter is filled:
RadGridView1.Relations.Clear()
Me.Table1TableAdapter.Fill(Me.Database8DataSet.Table1)
Me.RadGridView1.Relations.AddSelfReference(Me.RadGridView1.MasterTemplate, "TaskID", "ParentTask")
The RadGridView is bound to DataView
Workaround: add row using the DataTable API:
private void radButton1_Click(object sender, EventArgs e)
{
DataRow row = m_dvMat.Table.NewRow();
row["Active"] = true;
row["Category"] = form.m_sString;
m_dvMat.Table.Rows.Add(row);
}
To reproduce:
Add a TabControl and two tabs. In the second tab add a RadGridView and in the Load event of the form set the SplitMode property of the grid. You will notice that it will not have effect until grouping or other similar action has been performed.
Workaround:
private void Form1_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("column1");
dt.Columns.Add("column2");
RadGridView1.DataSource = dt;
this.RadGridView1.VisibleChanged += Visible_Changed;
}
private void Visible_Changed(object sender, EventArgs e)
{
if (this.RadGridView1.Visible & !this.RadGridView1.SplitMode.Equals(Telerik.WinControls.UI.RadGridViewSplitMode.Horizontal)) {
RadGridView1.SplitMode = Telerik.WinControls.UI.RadGridViewSplitMode.Horizontal;
}
}
To reproduce:
Add a RadGridView and use the following code to populate it:
for (int i = 0; i < 15; i++)
{
this.grid.Columns.Add(string.Format("Column {0}", i));
}
for (int i = 0; i < this.grid.Columns.Count * 15; i++)
{
this.grid.Rows.AddNew();
}t
Set the theme to TelerikMetroTouch.
Scroll somewhere below the middle leave the scrollbar and leave the grid with the mouse. You will notice that the value of the scrollbar will change.
Workaround:
Subscribe to the RadPropertyChanging event of the TableElement:
RadGridView1.TableElement.RadPropertyChanging += Property_Changing;
void TableElement_RadPropertyChanging(object sender, RadPropertyChangingEventArgs args)
{
args.Cancel = args.Property == GridTableElement.RowHeightProperty ||
args.Property == GridTableElement.TableHeaderHeightProperty ||
args.Property == GridTableElement.GroupHeaderHeightProperty ||
args.Property == GridTableElement.FilterRowHeightProperty;
}
To reproduce
- add Calculator column in the grid
- set the EnterKeyMode to EnterMovesToNextRow
- press enter when the cell is in edit mode.
Workaround:
-use custom GridDataRowBehavior like this:
class MyNewEnterBehavior : GridDataRowBehavior
{
bool firstTime = true;
protected override bool ProcessEnterKey(KeyEventArgs keys)
{
if (this.GridControl.IsInEditMode && this.GridControl.CurrentColumn is GridViewCalculatorColumn )
{
if (firstTime)
{
firstTime = false;
return false;
}
firstTime = true;
return base.ProcessEnterKey(keys);
}
return base.ProcessEnterKey(keys);
}
}
In RadGridView with a TextBoxColumn.
Set WrapText, Multiline and AcceptsReturn to true
If adding a new line, the return gives another new line instead of staying within the cell.
Workaround:
Create a new behavior class:
//VB
Class MyNewRowBehavior
Inherits GridNewRowBehavior
Protected Overrides Function ProcessEnterKey(keys As KeyEventArgs) As Boolean
If Me.GridControl.IsInEditMode AndAlso Me.GridControl.CurrentColumn.Name = "TextBoxColumn" Then
Dim editor As RadTextBoxEditor = TryCast(Me.GridControl.ActiveEditor, RadTextBoxEditor)
Dim element As RadTextBoxEditorElement = DirectCast(editor.EditorElement, RadTextBoxEditorElement)
element.Text.Insert(element.Text.Length, Environment.NewLine)
Return True
Else
Return MyBase.ProcessEnterKey(keys)
End If
End Function
End Class
//C#
class MyNewRowBehavior : GridNewRowBehavior
{
protected override bool ProcessEnterKey(KeyEventArgs keys)
{
if (this.GridControl.IsInEditMode && this.GridControl.CurrentColumn.Name == "TextBoxColumn")
{
RadTextBoxEditor editor = this.GridControl.ActiveEditor as RadTextBoxEditor;
RadTextBoxEditorElement element = (RadTextBoxEditorElement)editor.EditorElement;
element.Text.Insert(element.Text.Length, Environment.NewLine);
return true;
}
else
{
return base.ProcessEnterKey(keys);
}
}
}
then unregister the old behavior and register the new one:
//VB
DirectCast(radGridView1.GridBehavior, BaseGridBehavior).UnregisterBehavior(GetType(GridViewNewRowInfo))
DirectCast(radGridView1.GridBehavior, BaseGridBehavior).RegisterBehavior(GetType(GridViewNewRowInfo), New MyNewRowBehavior())
//C#
((BaseGridBehavior)radGridView1.GridBehavior).UnregisterBehavior(typeof(GridViewNewRowInfo));
((BaseGridBehavior)radGridView1.GridBehavior).RegisterBehavior(typeof(GridViewNewRowInfo), new MyNewRowBehavior());
Steps to reproduce:
1) Add RadGridView control
2) Use GridViewDecimalColumn:
DataTable customDataTable = new DataTable();
sampleDataTable.Columns.Add("Column name", typeof(double));
3) Set the right-to-left property of the control to true:
this.radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
4) Re-size the form manually until horizontal scroll-bar appears and you will notice that the left border is missing
Expected result: the left border of the GridRowHeaderCellElement is visible
Actual result: the left border of the GridRowHeaderCellElement is missing
Workaround:
this.radGridView1.ViewCellFormatting +=new CellFormattingEventHandler(radGridView1_ViewCellFormatting);
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement is GridRowHeaderCellElement)
{
e.CellElement.BorderLeftWidth = 3;
}
}
To reproduce:
Add a RadGridView to a form, dont dock it. Use the following code to add the rows, columns and the definition:
this.Grid.Columns.Add("Old");
this.Grid.Columns.Add("New");
Start the application and you will see that you cannot scroll to the end, horizontally.
Workaround:
Use the following code on a button click or execute it in a timer a few millisecond after the form has loaded in order to update the scrollbar's maximum value accordingly:
int width = 0;
foreach (var col in this.Grid.Columns)
{
width += col.Width;
}
this.Grid.TableElement.HScrollBar.Maximum = width - this.Grid.TableElement.HScrollBar.SmallChange - this.Grid.TableElement.RowHeaderColumnWidth;
How to reproduce:
Public Class Form1
Sub New()
InitializeComponent()
Dim col As New GridViewTextBoxColumn("Column1")
Me.RadGridView1.Columns.Add(col)
End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Dim sw As New Stopwatch
sw.Start()
Me.RadGridView1.Rows.Clear()
Me.RadGridView1.BeginUpdate()
Dim RowInfo
For ii = 1 To 100000
RowInfo = Me.RadGridView1.Rows.AddNew
RowInfo.Cells("Column1").Value = ii
Next
Me.RadGridView1.EndUpdate()
sw.Stop()
Console.WriteLine("Elapsed: " & sw.Elapsed.TotalSeconds)
End Sub
End Class
Workaround: add data to a collection and use bound mode
To reproduce: - Group the grid first. Make sure there are enough rows for two pages. - Set the AutoSizeRows property to true. Workaround: Set AutoSizeRows to false while printing.
The display member for empty string value in GridViewComboBoxColumn is not displayed. The following code reproduces the issue:
GridViewComboBoxColumn cboInsRslCd = new GridViewComboBoxColumn();
cboInsRslCd.DataType = typeof(string);
List<ItemComboBox> liste = new List<ItemComboBox>();
liste.Add(new ItemComboBox("", "[None]"));
liste.Add(new ItemComboBox("A", "A"));
liste.Add(new ItemComboBox("B", "B"));
liste.Add(new ItemComboBox("C", "C"));
cboInsRslCd.DataSource = liste;
cboInsRslCd.ValueMember = "CleItem";
cboInsRslCd.DisplayMember = "ValeurItem";
cboInsRslCd.NullValue = "[None]";
this.radGridView1.Columns.Add(cboInsRslCd);
WORKAROUND: subscribe to the CellEndEdit event and change the stored value in the event handler:
private void RadGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
{
if (e.Value == null)
{
e.Row.Cells[e.Column.Name].Value = "";
}
}
http://www.telerik.com/community/forums/radgridview-comboboxcolumn-displays-no-value-for-member-with-empty-string-value-is-selected
To reproduce:
1. Add a RadGridView and a RadButton.
2. Use the following code snippet:
Public Class Form1
Private myList As New List(Of MyObject)
Sub New()
InitializeComponent()
PopulateGrid(300)
End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
PopulateGrid(100)
End Sub
Private Sub PopulateGrid(count As Integer)
myList.Clear()
Me.RadGridView1.DataSource = Nothing
For index = 1 To count
myList.Add(New MyObject(index, "Item" & index))
Next
Me.RadGridView1.DataSource = myList
End Sub
Public Class MyObject
Public Sub New(ByVal myInt As Integer, ByVal myString As String)
_myInt = myInt
_myString = myString
End Sub
Private _myInt As Integer
Public Property MyInt() As Integer
Get
Return _myInt
End Get
Set(ByVal value As Integer)
_myInt = value
End Set
End Property
Private _myString As String
Public Property MyString() As String
Get
Return _myString
End Get
Set(ByVal value As String)
_myString = value
End Set
End Property
End Class
End Class
3. Select the last item
4. Click the button
Workaround: use BindingList instead of List