To reproduce: make sure only the first row is selected then Shift select row 3.
DataTable dt = new DataTable();
dt.Columns.Add("Value", typeof(int));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Description", typeof(string));
for (int index = 0; index < 15; index++)
{
dt.Rows.Add(new object[] { index % 5, DateTime.Now.AddSeconds(10), "Index = " + index });
}
radGridView1.DataSource = dt;
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGridView1.MultiSelect = true;
foreach (GridViewColumn col in this.radGridView1.Columns)
{
ConditionalFormattingObject obj = new ConditionalFormattingObject("Value",
ConditionTypes.Equal,
col.Index.ToString(),
"",
true);
obj.RowBackColor = Color.SkyBlue;
obj.RowForeColor = Color.Red;
obj.TextAlignment = ContentAlignment.MiddleRight;
obj.ApplyOnSelectedRows = false;
this.radGridView1.Columns[0].ConditionalFormattingObjectList.Add(obj);
}
Workaround: use the CellFormatting event to apply the desired formatting by using the API for overriding theme settings:
http://docs.telerik.com/devtools/winforms/gridview/cells/formatting-cells
http://docs.telerik.com/devtools/winforms/telerik-presentation-framework/override-theme-settings-at-run-time
How to reproduce:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.radGridView1.DataSource = this.GetData();
this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.Columns[0].DisableHTMLRendering = false;
this.radGridView1.PrintCellFormatting += radGridView1_PrintCellFormatting;
}
private void radGridView1_PrintCellFormatting(object sender, Telerik.WinControls.UI.PrintCellFormattingEventArgs e)
{
e.PrintCell.EnableHtmlTextRendering = true;
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Bool", typeof(bool));
dt.Columns.Add("Description", typeof(string));
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 5; j++)
{
dt.Rows.Add(@"<html><b>Name " + j, DateTime.Now.AddDays(i), i % 2 == 0 ? true : false, "Description " + i);
}
}
return dt;
}
private void radButton1_Click(object sender, EventArgs e)
{
GridPrintStyle style = new GridPrintStyle();
style.FitWidthMode = PrintFitWidthMode.FitPageWidth;
style.PrintGrouping = true;
style.PrintSummaries = false;
style.PrintHeaderOnEachPage = true;
style.PrintHiddenColumns = false;
style.CellPadding = new Padding(100, 0, 0, 0);
this.radGridView1.PrintStyle = style;
this.radGridView1.PrintPreview();
}
}
Workaround: refer to the attached project
To reproduce:
private void Form1_Load(object sender, EventArgs e)
{
this.productsTableAdapter.Fill(this.nwindDataSet.Products);
this.radGridView1.BestFitColumns(BestFitColumnMode.AllCells);
}
private void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if (e.CellElement is GridGroupContentCellElement)
{
e.CellElement.TextWrap = true;
}
else
{
e.CellElement.ResetValue(LightVisualElement.TextWrapProperty, ValueResetFlags.Local);
}
}
Workaround: set the AutoSizeColumnsMode property to GridViewAutoSizeColumnsMode.Fill and use the ViewCellFormatting event to wrap the text:
private void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if (e.CellElement is GridGroupContentCellElement)
{
e.CellElement.TextWrap = true;
}
else
{
e.CellElement.ResetValue(LightVisualElement.TextWrapProperty, ValueResetFlags.Local);
}
}
Please find attached a sample project. 1. Select the new row and activate te editor. 2. Do not enter any value and click outside the new row. The exception is thrown. Workaround: bind directly to the query result: this.radGridView1.DataSource = (from p in context.Customers select p).ToList();
Workaround: instead of using the default alternating row color for the mentioned themes, use the override theme setting in the CellFormatting event: http://www.telerik.com/help/winforms/tpf-override-theme-settings-at-run-time.html
private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.Row is GridViewDataRowInfo)
{
if (e.RowIndex % 2 == 0)
{
e.CellElement.SetThemeValueOverride(LightVisualElement.BackColorProperty, Color.Red, "");
e.CellElement.SetThemeValueOverride(LightVisualElement.DrawFillProperty, true, "");
e.CellElement.SetThemeValueOverride(LightVisualElement.GradientStyleProperty, GradientStyles.Solid, "");
}
else
{
e.CellElement.ResetThemeValueOverride(LightVisualElement.BackColorProperty, "");
e.CellElement.ResetThemeValueOverride(LightVisualElement.DrawFillProperty, "");
e.CellElement.ResetThemeValueOverride(LightVisualElement.GradientStyleProperty, "");
}
}
}
Currently the Paging functionality does not support server side operations. It should be extended to support them, e.g. with EntityFramework and Telerik Data Access
To reproduce:
Search a specific text by focusing the search box programmatically and the using the SendKeys method:
private void radButton1_Click(object sender, EventArgs e)
{
GridSearchCellElement searchCell = radGridView1.TableElement.GetCellElement(radGridView1.MasterView.TableSearchRow, null) as GridSearchCellElement;
if (searchCell != null)
{
searchCell.SearchTextBox.Focus();
searchCell.SearchTextBox.Text = string.Empty;
SendKeys.Send("t");
SendKeys.Send("e");
SendKeys.Send("s");
SendKeys.Send("t");
}
}
Workaround:
Repeat the search in the SearchProgressChanged event:
radGridView1.MasterView.TableSearchRow.SearchProgressChanged += TextationSearchProgressHandler;
protected void TextationSearchProgressHandler(object sender, SearchProgressChangedEventArgs e)
{
if (e.SearchFinished && null != radGridView1.TableElement)
{
GridSearchCellElement searchCell = radGridView1.TableElement.GetCellElement(radGridView1.MasterView.TableSearchRow, null) as GridSearchCellElement;
if (searchCell != null
&& searchCell.SearchTextBox.TextBoxItem.Text != e.SearchCriteria)
{
radGridView1.MasterView.TableSearchRow.Search(searchCell.SearchTextBox.TextBoxItem.Text);
}
}
}
To reproduce:
public Form1()
{
InitializeComponent();
DataTable dt = new DataTable();
for (int i = 0; i < 5; i++)
{
dt.Columns.Add("Col"+i);
}
for (int i = 0; i < 2000; i++)
{
DataRow row = dt.NewRow();
foreach (DataColumn col in dt.Columns)
{
row[col.ColumnName] = "Data" + i + "." + dt.Columns.IndexOf(col);
}
dt.Rows.Add(row);
}
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
}
private void radButton1_Click(object sender, EventArgs e)
{
RadPrintPreviewDialog dialog = new RadPrintPreviewDialog();
dialog.Document = this.radPrintDocument1;
dialog.ShowDialog();
}
Workaround: this.radGridView1.AutoSizeRows = true;
To reproduce: use the following code snippet. You will notice that the "Accounting Manager" group is missing.
private void Form1_Load(object sender, EventArgs e)
{
this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
this.radGridView1.DataSource = this.customersBindingSource;
ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
view.ColumnGroups.Add(new GridViewColumnGroup("Customer Contact"));
view.ColumnGroups.Add(new GridViewColumnGroup("Details"));
view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Address"));
view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Contact"));
view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[0].Rows[0].ColumnNames.Add("CompanyName");
view.ColumnGroups[0].Rows[0].ColumnNames.Add("ContactName");
view.ColumnGroups[0].Rows[0].ColumnNames.Add("ContactTitle");
view.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Groups[0].Rows[0].ColumnNames.Add("Address");
view.ColumnGroups[1].Groups[0].Rows[0].ColumnNames.Add("City");
view.ColumnGroups[1].Groups[0].Rows[0].ColumnNames.Add("Country");
view.ColumnGroups[1].Groups[1].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Groups[1].Rows[0].ColumnNames.Add("Phone");
view.ColumnGroups[1].Groups[1].Rows[0].ColumnNames.Add("Fax");
radGridView1.ViewDefinition = view;
GroupDescriptor descriptor = new GroupDescriptor();
descriptor.GroupNames.Add("ContactTitle", ListSortDirection.Ascending);
this.radGridView1.GroupDescriptors.Add(descriptor);
this.radGridView1.Groups[0].GroupRow.IsPinned = true;
}
Please refer to the attached screenshot and sample video.
Workaround:
public class CustomGrid : RadGridView
{
public override string ThemeClassName
{
get
{
return typeof(RadGridView).FullName;
}
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
this.BeginEdit();
if (this.GridViewElement.ActiveEditor is RadDropDownListEditor)
{
string symbol = e.KeyChar.ToString();
RadDropDownListEditor editor = this.GridViewElement.ActiveEditor as RadDropDownListEditor;
RadDropDownListEditorElement element = editor.EditorElement as RadDropDownListEditorElement;
if ((element.AutoCompleteMode & AutoCompleteMode.Suggest) == AutoCompleteMode.Suggest)
{
element.EditableElementText += symbol;
element.EditableElement.SelectionStart = 1;
element.EditableElement.SelectionLength = 0;
}
}
base.OnKeyPress(e);
}
}
To reproduce:
private void Form1_Load(object sender, EventArgs e)
{
this.productsTableAdapter.Fill(this.nwindDataSet.Products);
this.categoriesTableAdapter.Fill(this.nwindDataSet.Categories);
radGridView1.AllowSearchRow = true;
radGridView1.DataSource = nwindDataSet.Categories;
radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGridView1.UseScrollbarsInHierarchy = true;
GridViewTemplate template = new GridViewTemplate();
template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
template.DataSource = nwindDataSet.Products;
radGridView1.MasterTemplate.Templates.Add(template);
GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "CategoriesProducts";
relation.ParentColumnNames.Add("CategoryID");
relation.ChildColumnNames.Add("CategoryID");
radGridView1.Relations.Add(relation);
}
Workaround:
private void radGridView1_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e)
{
if (this.radGridView1.CurrentRow != null)
{
if (this.radGridView1.CurrentRow.HierarchyLevel > 0)
{
tableElement.ScrollToRow((GridViewHierarchyRowInfo)(this.radGridView1.CurrentRow).Parent);
this.radGridView1.TableElement.EnsureRowVisible((GridViewHierarchyRowInfo)(this.radGridView1.CurrentRow).Parent);
tableElement.ScrollToRow(this.radGridView1.CurrentRow);
tableElement.EnsureRowVisible(this.radGridView1.CurrentRow);
}
}
}
To reproduce: use the following code snippet. From the filtering box, when you select "Null" and then select "All", the following error occurs:
Item has already been added. Key in dictionary: '(Blanks)' Key being added: '(Blanks)'
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Rows.Add(1,"A");
dt.Rows.Add(2, "");
dt.Rows.Add(3, null);
dt.Rows.Add(4, "B");
dt.Rows.Add(5, "C");
dt.Rows.Add(6, "");
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.EnableFiltering = true;
this.radGridView1.ShowFilteringRow = false;
this.radGridView1.ShowHeaderCellButtons = true;
Workaround: this.radGridView1.FilterPopupInitialized += radGridView1_FilterPopupInitialized;
RadListFilterDistinctValuesTable selectedValues;
private void radGridView1_FilterPopupInitialized(object sender, Telerik.WinControls.UI.FilterPopupInitializedEventArgs e)
{
RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup;
selectedValues = popup.MenuTreeElement.SelectedValues;
popup.MenuTreeElement.TreeView.NodeCheckedChanged += TreeView_NodeCheckedChanged;
}
private void TreeView_NodeCheckedChanged(object sender, TreeNodeCheckedEventArgs e)
{
if (e.Node.CheckState == Telerik.WinControls.Enumerations.ToggleState.Off)
{
if (selectedValues.Contains(e.Node.Text))
{
selectedValues.Remove(e.Node.Text);
}
}
}
Workaround: use a custom BaseGridBehavior
public Form1()
{
InitializeComponent();
this.radGridView1.GridBehavior = new MyBaseGridBehavior();
}
public class MyBaseGridBehavior : BaseGridBehavior
{
public override bool ProcessKey(KeyEventArgs keys)
{
if (keys.Control && this.GridControl.CurrentColumn == null)
{
return false;
}
return base.ProcessKey(keys);
}
}
Add a Card view layout.
To reproduce:
radGridView1.GridNavigator.SelectFirstRow();
for (int i = 0; i < radGridView1.RowCount; i++)
{
var result = radGridView1.GridNavigator.SelectNextRow(1);
}
Workaround:
- Move to the last row first:
radGridView1.GridNavigator.SelectLastRow();
Workaround: suspend columns notifications when preview dropping and resume the notification after the drag drop service has stopped:
Dim svc As RadDragDropService = Me.RadGridView1.GridViewElement.GetService(Of RadDragDropService)()
AddHandler svc.Stopped, svc_Stopped
AddHandler svc.PreviewDragDrop, AddressOf svc_PreviewDragDrop
Private Sub svc_PreviewDragDrop(sender As Object, e As RadDropEventArgs)
For Each col As GridViewColumn In Me.RadGridView1.Columns
col.SuspendPropertyNotifications()
Next
End Sub
Private Function svc_Stopped() As Object
For Each col As GridViewColumn In Me.RadGridView1.Columns
col.ResumePropertyNotifications()
Next
End Function
To reproduce:
public Form1()
{
InitializeComponent();
BindingList<Item> items = new BindingList<Item>();
for (int i = 0; i < 30; i++)
{
if (i % 3 == 0)
{
items.Add(new Item(i,"Item" + i, IndeterminateBoolean.YesAndNo));
}
else if (i % 3 == 1)
{
items.Add(new Item(i, "Item" + i, IndeterminateBoolean.Yes));
}
else
{
items.Add(new Item(i, "Item" + i, IndeterminateBoolean.No));
}
}
this.radGridView1.DataSource = items;
GridViewCheckBoxColumn checkBox = new GridViewCheckBoxColumn("CheckBoxCol");
checkBox.DataTypeConverter = new IndeterminateBooleanToggleStateConverter();
checkBox.FieldName = "IsActive";
checkBox.ThreeState = true;
this.radGridView1.Columns.Add(checkBox);
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.EnableFiltering = true;
this.radGridView1.ShowHeaderCellButtons = true;
this.radGridView1.ShowFilteringRow = false;
}
public class Item
{
public int Id { get; set; }
public string Name { get; set; }
public IndeterminateBoolean IsActive { get; set; }
public Item(int id, string name, IndeterminateBoolean isActive)
{
this.Id = id;
this.Name = name;
this.IsActive = isActive;
}
}
public enum IndeterminateBoolean
{
No,
Yes,
YesAndNo
}
public class IndeterminateBooleanToggleStateConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(ToggleState);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(ToggleState);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is ToggleState)
{
switch ((ToggleState)value)
{
case ToggleState.On:
return IndeterminateBoolean.Yes;
case ToggleState.Off:
return IndeterminateBoolean.No;
case ToggleState.Indeterminate:
default:
return IndeterminateBoolean.YesAndNo;
}
}
else
{
return base.ConvertFrom(context, culture, value);
}
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(ToggleState))
{
if (value is IndeterminateBoolean)
{
switch ((IndeterminateBoolean)value)
{
case IndeterminateBoolean.Yes:
return ToggleState.On;
case IndeterminateBoolean.No:
return ToggleState.Off;
case IndeterminateBoolean.YesAndNo:
default:
return ToggleState.Indeterminate;
}
}
if (value is string)
{
switch (((string)value ?? string.Empty).Trim())
{
case "Yes":
return ToggleState.On;
case "No":
case "":
return ToggleState.Off;
case "Both":
default:
return ToggleState.Indeterminate;
}
}
else
{
return base.ConvertTo(context, culture, value, destinationType);
}
}
else
{
return base.ConvertTo(context, culture, value, destinationType);
}
}
}
Workaround: use the custom filtering functionality: http://docs.telerik.com/devtools/winforms/gridview/filtering/custom-filtering
You can access the RadGridView.FilterDescriptors collection and according to the FilterDescriptor.Expression property to determine whether the row will be visible or not.
To reproduce:
public Form1()
{
InitializeComponent();
BindingList<Item> items = new BindingList<Item>();
for (int i = 0; i < 30; i++)
{
if (i % 3 == 0)
{
items.Add(new Item(i,"Item" + i, IndeterminateBoolean.YesAndNo));
}
else if (i % 3 == 1)
{
items.Add(new Item(i, "Item" + i, IndeterminateBoolean.Yes));
}
else
{
items.Add(new Item(i, "Item" + i, IndeterminateBoolean.No));
}
}
this.radGridView1.DataSource = items;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.EnableFiltering = true;
this.radGridView1.ShowHeaderCellButtons = true;
this.radGridView1.ShowFilteringRow = false;
}
public class Item
{
public int Id { get; set; }
public string Name { get; set; }
public IndeterminateBoolean IsActive { get; set; }
public Item(int id, string name, IndeterminateBoolean isActive)
{
this.Id = id;
this.Name = name;
this.IsActive = isActive;
}
}
public enum IndeterminateBoolean
{
No,
Yes,
YesAndNo
}
Workaround: use custom filtering http://docs.telerik.com/devtools/winforms/gridview/filtering/custom-filtering
To reproduce:
Add the following view:
for (int i = 0; i < 8; i++)
{
radGridView2.Columns.Add("Col" + (i+1));
}
ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
view.ColumnGroups.Add(new GridViewColumnGroup("G1"));
view.ColumnGroups.Add(new GridViewColumnGroup("G2"));
view.ColumnGroups.Add(new GridViewColumnGroup("G3"));
view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[0].Rows[0].ColumnNames.Add("Col1");
view.ColumnGroups[0].Rows[0].ColumnNames.Add("Col2");
view.ColumnGroups[0].Rows[0].ColumnNames.Add("Col3");
view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Rows[0].ColumnNames.Add("Col4");
view.ColumnGroups[1].Rows[0].ColumnNames.Add("Col5");
view.ColumnGroups[2].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[2].Rows[0].ColumnNames.Add("Col6");
view.ColumnGroups[2].Rows[0].ColumnNames.Add("Col7");
view.ColumnGroups[2].Rows[0].ColumnNames.Add("Col8");
radGridView2.ViewDefinition = view;
for (int i = 0; i < 10; i++)
{
radGridView2.Rows.Add("row"+i, "test","test","test","test","test","test");
}
radGridView2.Columns[2].IsVisible = false;
radGridView2.Columns[7].IsVisible = false;
- Then export the grid with the spread exporter.
When the RadGridView.EnabledPaging property is set to true, the user should be allowed to specify not only the PageSize,but also the PagesCount for example. Afterwards, it would be convenient to have an event similar to RowSourceNeeded in order to load pages data on demand.