Saving a form with RadGridView produces the following error at design time: Code generation for property "PrintCellPaint" failed. We isolated the following steps which reproduce the issue: 1. Drag and drop RadPageView on the form. Add 2 pages. 2. Add a RadGridView to one of the pages. 3. Saved and opened the form. 4. Select the other page and save the form. case #1: If the grid is empty - Code generation for property 'PrintCellPaint' failed. Error was: 'Object does not match type.' case #2: If the grid is data bound - Code generation for property 'PropertyChanging' failed. Error was: 'Object does not match type.' The same errors if you use RadDock with tabbed documents.
It does not matter the type of the control that we want to move the focus on as well as if it was RadControl or not
To reproduce:
private void radGridView1_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e)
{
e.Cancel = true;
// Some other control to move the focus on
this.textBox1.Focus();
}
Workaround:
Before cancelling the event set the value of the active editor to the current cell value
private void radGridView1_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e)
{
this.radGridView1.ActiveEditor.Value = e.Row.Cells[e.Column.Name].Value;
e.Cancel = true;
// Some other control to move the focus on
this.textBox1.Focus();
}
The conditional formatting collection get deleted after closing the property builder. To reproduce : Add a gridview with a datasource. Open property builder Select a column Advance -> ConditionalFormattingObjectList Add a expression, set a name Press Ok If you click the ConditionalFormattingObjectList, you can see the expression If you click close the Property Builder, the list is not saved when you open it again.
To reproduce:
- Enable the search row in the grid.
- Enter some text in the search text box in order to mark some rows.
- Refresh the master template.
- Notice that the text is cleared, but the formatting remains.
Workaround, use the following custom cell:
class MyGridSearchCellElement : GridSearchCellElement
{
public MyGridSearchCellElement(GridViewColumn column, GridRowElement row)
:base (column, row)
{
}
bool performSearch = true;
protected override void SyncLabelText()
{
//base.SyncLabelText();
GridViewSearchRowInfo searchRow = this.RowInfo as GridViewSearchRowInfo;
if (searchRow == null)
{
return;
}
performSearch = false;
string searchCriteria = typeof(GridViewSearchRowInfo).GetField("searchCriteria", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(searchRow).ToString();
if (string.IsNullOrEmpty(searchCriteria))
{
this.SearchTextBox.Text = String.Empty;
this.SearchTextBox.SearchInfoLabel.Text = String.Empty;
}
else
{
this.SearchTextBox.Text = searchCriteria;
this.SearchTextBox.SearchInfoLabel.Text = string.Format("{0} {1} {2}", searchRow.CurrentResultIndex + 1, Telerik.WinControls.UI.Localization.RadGridLocalizationProvider.CurrentProvider.GetLocalizedString(Telerik.WinControls.UI.Localization.RadGridStringId.SearchRowResultsOfLabel), searchRow.CurrentSearchResultsCount);
}
performSearch = true;
}
protected override void Search()
{
if (!performSearch)
{
return;
}
base.Search();
}
}
To put it in action, use the CreateCell event of RadGridView:
void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
if (e.CellType == typeof( GridSearchCellElement))
{
e.CellElement = new MyGridSearchCellElement(e.Column, e.Row);
}
}
RADGRIDVIEW Extend it with the following localization string ids:
– RadGridStringId.FilterMenuSelectionTrue
– RadGridStringId.FilterMenuSelectionFalse
Resolution:
The mentioned strings are not predefined strings within RadGridView. They come from the values of the column being filtered (e.g. if the column is a checkbox column, all values are either True or False). Therefore, to localize them, you need to use a ValueConverter and override the conversion to string:
this.radGridView1.Columns[3].DataTypeConverter = new MyConverter();
class MyConverter : BooleanConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string))
{
if (Object.Equals(value, "True") || (value is bool && (bool)value))
return "Yes";
if (Object.Equals(value, "False") || (value is bool && !(bool)value))
return "No";
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
To reproduce:
string fileName = @"..\..\..\exported" + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".xlsx";
SpreadExport spreadExporter = new SpreadExport(radGridView1);
spreadExporter.ExportVisualSettings = false;
spreadExporter.RunExport(fileName);
Workaround:
spreadExporter.WorkbookCreated += spreadExporter_WorkbookCreated;
private void spreadExporter_WorkbookCreated(object sender, WorkbookCreatedEventArgs e)
{
Telerik.Windows.Documents.Spreadsheet.PropertySystem.CellStyle defaultStyle = e.Workbook.Styles.Add("DefaultStyle");
defaultStyle.FontSize = Telerik.Windows.Documents.Spreadsheet.Utilities.UnitHelper.PointToDip(11);
Telerik.Windows.Documents.Spreadsheet.Model.Worksheet sheet = e.Workbook.Worksheets.First();
sheet.Cells[0, 0, sheet.UsedCellRange.RowCount, sheet.UsedCellRange.ColumnCount].SetStyleName("DefaultStyle");
sheet.Columns[sheet.UsedCellRange].AutoFitWidth();
}
To reproduce use the following snippets in the CellFormatting event of the exporter: ThemableColor red = new ThemableColor(System.Windows.Media.Colors.Red); CellBorders redBorders = new CellBorders(new CellBorder(CellBorderStyle.Medium, red)); e.CellStyleInfo.Borders = redBorders; or ThemableColor red = new ThemableColor(System.Windows.Media.Colors.Red); CellBorders fourBorders = new CellBorders(); fourBorders.Top = new CellBorder(CellBorderStyle.Thin, red); fourBorders.Bottom = new CellBorder(CellBorderStyle.Thin, red); fourBorders.Right = new CellBorder(CellBorderStyle.Thin, red); fourBorders.Left = new CellBorder(CellBorderStyle.Thin, red); e.CellStyleInfo.Borders = fourBorders;
Hello,
I succeed to reproduce the GridViewComboboxColumn exception in this forum post:
http://www.telerik.com/forums/nullreferenceexception-4a6181b2453b#cwDrbIqzp0CPxcgh90b4rQ
I attach a sample project, the database (SQL Server 2012 Express) and a video from the exception.
To reproduce:
- Run the project,
- Sort the column "Állapot" descending.
- Click on column and drop down the list.
- Choose an another value, and click very fast twice. On a slow PC is much easier to reproduce the issue. The important thing, that you need select a value from the combobox and select another row very fast. (See the attached video)
I use the latest Trial version of Winforms.
If you have any question, please contact me.
Best Regards,
László
Workaround:
Private Sub gridMunkak_CreateCell(sender As Object, e As GridViewCreateCellEventArgs) Handles gridMunkak.CreateCell
If e.CellType = GetType(GridComboBoxCellElement) Then
e.CellElement = New MyGridComboBoxCellElement(e.Column, e.Row)
End If
End Sub
Public Class MyGridComboBoxCellElement
Inherits GridComboBoxCellElement
Public Sub New(column As GridViewColumn, row As GridRowElement)
MyBase.New(column, row)
End Sub
Public Overrides Sub SetContent()
If Me.ColumnInfo IsNot Nothing Then
MyBase.SetContent()
End If
End Sub
Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
Get
Return GetType(GridComboBoxCellElement)
End Get
End Property
End Class
To reproduce:
1. Add a RadGridView and a RadButton.
2. Populate the grid with data and call the BestFitColumns( BestFitColumnMode.AllCells) method (or resize the columns).
3. Set its RightToLeft property to Windows.Forms.RightToLeft.Yes.
3. In the RadButton.Click event handler call the RadGridView.PrintPreview(). As a result the columns are shrunk. Please see the attached gif file.
Workaround:
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Me.RadGridView1.BeginUpdate()
Me.RadGridView1.PrintPreview()
Me.RadGridView1.EndUpdate()
Me.RadGridView1.BestFitColumns(BestFitColumnMode.AllCells)
End Sub
To reproduce:
- Create a custom column that uses RadTextBoxControlElement as permanent editor.
- Add the column to the grid.
- Scroll the grid so the custom column is not visible.
- Put the the grid in edit mode and change the current cell.
Workaround:
- Disable the IME support:
public class MyRadTextBoxControlElement : RadTextBoxControlElement
{
protected override Type ThemeEffectiveType
{
get
{
return typeof(RadTextBoxControlElement);
}
}
protected override void OnLoaded()
{
this.InvalidateMeasure();
}
}
If a RadGridView instance is not disposed explicitly and it is left for the finalizer to dispose, a null reference exception will be thrown. This can happen if the grid is not in the control tree of a form. The exception is caused by the fact that the SelfReferenceDataProvider is disposed twice in this case.
Workaround:
RadImageShape hint;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
InitializeComponent();
hint = radGridView1.TableElement.RowDragHint;
new Windows7Theme();
radGridView1.ThemeName = "Windows7";
radGridView1.TableElement.RowDragHint = hint;
}
The issue appears when selecting multiple cells using mouse drag outside of the bounds of the control. Add a large number of columns (100) and a few rows, press the first cell and drag quickly as far to the right as possible. When you scroll back and check the selection, you will see that some cells are not selected.
ADD. RadGridView - add ability to move the column with the expanders to different position then the first one Resolution: Set the SelfReferenceExpanderColumn property of the MasterTemplate to the preferred column. Here is the code snippet: radGridView1.MasterTemplate.SelfReferenceExpanderColumn = this.radGridView1.MasterTemplate.Columns[4];
To reproduce: - Open the Search Row sample in the demo application. - Type some text in the search textbox. - Using the context menu of the search textbox add some unicode control characters.
private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
GridColorPickerEditor colorEditor = e.ActiveEditor as GridColorPickerEditor;
if (colorEditor!=null)
{
GridColorPickerElement colorPicker = colorEditor.EditorElement as GridColorPickerElement;
colorPicker.ReadOnly = true;
}
}
Please refer to the attached gif file.
Workaround:
private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
{
if (e.EditorType == typeof(GridColorPickerEditor))
{
e.Editor = new GridColorPickerEditor();
}
}
To reproduce: - Add grid to a form and populate it with data. - Show and hide the the excel like filtering several times.
To reproduce: - Add GridViewCheckBoxColumn and set the EnableHeaderCheckBox property to true. - Mark all check boxes and change the data source of the grid (use one where not all values are set to true). Workaround: Add new column when the data source is changed.
To reproduce:
- Add checkbox column to a grid and enable filtering.
- Filter on other column so there are no rows visible.
- The header cell checkbox is checked automatically.
Workaround:
void radGridView_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
if (e.CellType == typeof(GridCheckBoxHeaderCellElement))
{
e.CellElement = new GridCheckBoxHeaderCellElement(e.Column,e.Row);
((GridCheckBoxHeaderCellElement)e.CellElement).CheckBox.ToggleStateChanging += CheckBox_ToggleStateChanging;
}
}
void CheckBox_ToggleStateChanging(object sender, StateChangingEventArgs args)
{
if (radDevices.ChildRows.Count == 0)
{
args.Cancel = true;
}
}