Setting the custom format is not applied to the cell. To reproduce:
Dim customColumn As New GridViewDateTimeColumn()
customColumn.Width = 200
customColumn.Name = "custom"
customColumn.EditorType = GridViewDateTimeEditorType.TimePicker
customColumn.FormatString = "{0:HH:mm}"
customColumn.Format = DateTimePickerFormat.Custom
customColumn.CustomFormat = "HH:mm"
RadGridView1.MasterTemplate.Columns.Add(customColumn)
RadGridView1.Rows.Add(DateTime.Now)
To reproduce:
Declare the following classes:
public class Test
{
public string Name { get; set; }
public Child Child { get; set; }
}
public class Child
{
public string ChildName { get; set; }
public override string ToString()
{
return ChildName;
}
}
Add the following columns:
gridViewTextBoxColumn1.FieldName = "Name";
gridViewTextBoxColumn1.HeaderText = "column1";
gridViewTextBoxColumn1.Name = "column1";
gridViewTextBoxColumn2.FieldName = "Child";
gridViewTextBoxColumn2.HeaderText = "column2";
gridViewTextBoxColumn2.Name = "column2";
this.radGridView1.MasterTemplate.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] {
gridViewTextBoxColumn1,
gridViewTextBoxColumn2});
this.radGridView1.Name = "radGridView1";
this.radGridView1.Size = new System.Drawing.Size(429, 176);
this.radGridView1.TabIndex = 0;
this.radGridView1.Text = "radGridView1";
Bind RadGridView to the following data:
var data = new List<Test>();
for (int i = 0; i < 10; i++)
{
data.Add(new Test
{
Name = "Name" + i,
Child = new Child
{
ChildName = "Child " + i
}
});
}
Export to Excel:
ExportToExcelML excelExporter = new ExportToExcelML(radGridView1);
excelExporter.RunExport(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"test.xls"));
You will notice that column2 will not have text
Workaround:
Subscribe to the ExcelCellFormatting event:
void excelExporter_ExcelCellFormatting(object sender, Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e)
{
if (e.ExcelCellElement.Data.DataItem.GetType().IsClass)
{
e.ExcelCellElement.Data.DataItem = e.ExcelCellElement.Data.DataItem.ToString();
}
}
Resolution: Please use the following code snippet to replace RadGridViewDragDropService: this.radGridView1.GridViewElement.RegisterService(new CustomDragDropService(this.radGridView1.GridViewElement));
To reproduce: - Create a RadGridView with 3 columns. - Set ShowRowHeaderColumn to false. - Set GridViewAutoSizeColumnsMode to Fill. - Select a cell and hit the TAB key multiple times. Notice the entire grid shift left and right.
This method should return true if successful.
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