WORKAROUND:
The format of the file that ExportToExcelML creates is ExcelML which is an extended XML. If you do not want to receive the message, you have to change the extension of the file to ".xml". Even though the file will have an xml extension, it will still be associated with MS Excel and will be opened by Excel.There is a possibility to turn this warning message off on the client machine. You can read more about that on the following blog post - Excel 2007 Extension Warning On Opening Excel Workbook from a Web Site (http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.aspx)
Another workaround is to use Interop to open the file and excel and save it in XLSX format. However, this would require Administrator or Power User (http://msdn.microsoft.com/en-us/library/ms173186%28v=vs.80%29.aspx). A reference from COM to the corresponding office version should be added. Here is the code for saving:
ExportToExcelML exporter = new ExportToExcelML(this.radGridView1);
exporter.ExportVisualSettings = true;
string tempPath = Path.GetTempPath();
tempPath += "tempgrid.xls";
exporter.RunExport(tempPath);
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
if (app == null)
{
Console.WriteLine("EXCEL could not be started. Check that your office installation and project references are correct.");
return;
}
app.Visible = false;
app.Interactive = false;
Microsoft.Office.Interop.Excel.Workbook wb = app.Workbooks.Open(tempPath);
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
desktopPath += "\\grid.xlsx";
wb.SaveAs(desktopPath, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault);
wb.Close();
app.Quit();
Marshal.ReleaseComObject(wb);
Marshal.ReleaseComObject(app);
File.Delete(tempPath);
When RadGridView is displaying a self-referencing it should be able to show the data with ColumnGroupsViewDefinition and HtmlViewDefinition.
When UseCompatibleTextRendering property is set to false, the data cells overlaps the row header cells when horizontal scrolling is performed.
Steps to reproduce: 1. Place a grid on a form and add several columns. 2. Set a ColumnGroupsViewDefinition to the grid and resize the columns so the horizontal scroll bar appears. 3. Add a button and on its click call the PrintPreview method of the grid. You will see that the horizontal scroll bar of the grid will disappear. Workaround:workaround it by increasing and decreasing the width of a single column with 1 pixel right after you call the Print method of the print document. document.Print() grid.Columns(0).Width += 1 grid.Columns(0).Width -= 1
1. Create a new project with RadGridView and bind it. 2. Setup 2 level grouping. 3. Add top summary row. 4. Set the ShowParentGroupSummaries property to true. 5. Run the project and expand a group. 6. Edit a cell from a column that has a summary item attached. 7. Notice that the parent summary row is not updated properly.
If a dock window is focused programmatically, the RowValidating event is fired before selecting the new row by mouse cursor.
To reproduce:
- use the code below to create an application
- start it and click the Id column twice (so you will sort it first ascending and then descending)
- double click the first row (with ID=9) => the BindingList current is still the row with ID 0, while it should be the row with ID 9
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SetDefaults();
}
private void SetDefaults()
{
radGridView1.MasterTemplate.AutoGenerateColumns = false;
radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;
radGridView1.MasterTemplate.EnableAlternatingRowColor = true;
radGridView1.TableElement.AlternatingRowColor = Color.FromArgb(0xEB, 0xEF, 0xFB);
radGridView1.MasterTemplate.ShowGroupedColumns = true;
radGridView1.MasterTemplate.EnableGrouping = true;
radGridView1.MasterTemplate.MultiSelect = false;
radGridView1.EnableFiltering = true;
radGridView1.EnableFastScrolling = true;
radGridView1.TableElement.TableHeaderHeight = 50;
}
private void Form1_Load(object sender, EventArgs e)
{
var users = new EmployeeList();
for (int i = 0; i < 10; i++)
{
var user = new Employee();
user.Id = i;
user.Name = "John Doe " + i;
users.Add(user);
}
employeeListBindingSource.DataSource = users;
}
private void radGridView1_CellDoubleClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
if (e.RowIndex == -1 || e.Row.RowElementType != typeof(GridDataRowElement) || !(e.Row is GridViewDataRowInfo))
return;
var selectedUser = employeeListBindingSource.Current as Employee;
MessageBox.Show(selectedUser.Name);
}
}
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public Employee()
{
}
}
public class EmployeeList : BindingList<Employee>
{
public EmployeeList()
{
}
}
There should be a way to determine if the row was deleted through the cell or row header context menu or by pressing the delete key.
Copy of cells from second level in hierarchy does not work.
To reproduce: rgvTest.BeginUpdate() For ixTest As Integer = 1 To 2000 Dim rgvrTest As GridViewRowInfo = rgvTest.Rows.AddNew rgvrTest.Cells(0).Value = "Value " & ixTest.ToString Next rgvTest.EndUpdate() rgvTest.Rows(0).IsCurrent = True MessageBox.Show(rgvTest.CurrentCell.RowIndex.ToString)
1. Create a RadGridView and setup hierarchy. 2. Add a group descriptor and several rows in the child view so that when expanding it scrollbar appears. 3. Run the project and expand the first row (there should be only one row at first level and one group at second level).
1. Create a new project with RadGridView. 2. Bind it to a business object collection without rows. 3. Add a descending sort descriptor for a date time column. 4. Add a button and on its click event add a new row to the collection. The new row should have first column with data which produces different sort results than the date time column. 5. Run the project and add some rows.
To reproduce - Have a page view with two pages - one empty and one with a grid - put some cell in the grid in edit mode and cancel its validation in the CellValidating event - at this point you cannot change the current cell in the grid (which is desired) but you are able to switch to another page in the page view, thus its SelectedPageChanging event fires (which is not desired)
Exception is thrown when a property of data bound record is changed and filtering is applied
To reproduce - bind the grid to a binding list - pin one of the rows - delete this row from the binding list - click somewhere on the grid => exception is thrown
Plese download the attached project and run it. It uses some of our internal data so plese keep it private. Once you get the GridView with the data do the following: 1. Click on "Mahine speed" Header to change sort order. 2. Open "Mahine speed" filter and deselect all and select 1 3. Open "Mahine speed" filter and deselect 1 and select 2 4. Open "Mahine speed" filter and deselect 2 and select 3 5. Open "Mahine speed" filter and deselect 3 and select 1 At this point you get the crash. The above steps are for you to be able to reproduce the issue,, in general terms, the issue happens if I reproduce the same steps in any Combobox column. This is causing crashes all along my project since most of the forms in my project are gridviews and users use a lot sorting and filtering to get to the needed data.
NullReferenceException when the Text property of RadDropDownListEditor is initialized with null value in the CellEditorInitialized event.
To reproduce use the code above and when the application starts double click the column in order to best fit it : RadGridView radGridView1 = new RadGridView();
this.Controls.Add(radGridView1);
radGridView1.Columns.Add("some text");
radGridView1.HideSelection = true;
1. Create a new project with RadGridView and set MultiSelect to true and SelectionMode to CellSelect.
2. Run the project.
3. Use the mouse to select some cells and scroll down while selecting.
4. Remove some cells from the selection.
5. Scroll with the scrollbar up to the first selected cells. You will see that all previously selected cells which are not visible are not selected.
Workaround:
Use the following custom behavior:
public class MyGridRowBehavior : GridDataRowBehavior
{
private FieldInfo oldCurrentLocationFieldInfo;
private Point oldCurrentLocation
{
get
{
if (this.oldCurrentLocationFieldInfo == null)
{
this.oldCurrentLocationFieldInfo = typeof(GridRowBehavior).GetField("oldCurrentLocation", BindingFlags.Instance | BindingFlags.NonPublic);
}
return (Point)this.oldCurrentLocationFieldInfo.GetValue(this);
}
set
{
this.oldCurrentLocationFieldInfo.SetValue(this, value);
}
}
private MethodInfo selectIntersectedCellsMethodInfo;
private delegate void SelectIntersectedCellsDelegate(RadElementCollection rows, bool isProcessedShiftOrControl);
private SelectIntersectedCellsDelegate SelectIntersectedCellsCore;
private void SelectIntersectedCells(RadElementCollection rows, bool isProcessedShiftOrControl)
{
if (this.selectIntersectedCellsMethodInfo == null)
{
this.selectIntersectedCellsMethodInfo = typeof(GridRowBehavior).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).First(x => x.Name == "SelectIntersectedCells" && x.GetParameters().Length == 2);
this.SelectIntersectedCellsCore = (SelectIntersectedCellsDelegate)Delegate.CreateDelegate(typeof(SelectIntersectedCellsDelegate), this, this.selectIntersectedCellsMethodInfo);
}
this.SelectIntersectedCellsCore(rows, isProcessedShiftOrControl);
}
private MethodInfo selectIntersectedRowsMethodInfo;
private delegate bool SelectIntersectedRowsDelegate(RadElementCollection rows);
private SelectIntersectedRowsDelegate SelectIntersectedRowsCore;
private bool SelectIntersectedRows(RadElementCollection rows)
{
if (this.selectIntersectedRowsMethodInfo == null)
{
this.selectIntersectedRowsMethodInfo = typeof(GridRowBehavior).GetMethod("SelectIntersectedRows", BindingFlags.Instance | BindingFlags.NonPublic);
this.SelectIntersectedRowsCore = (SelectIntersectedRowsDelegate)Delegate.CreateDelegate(typeof(SelectIntersectedRowsDelegate), this, this.selectIntersectedRowsMethodInfo);
}
return this.SelectIntersectedRowsCore(rows);
}
protected override bool ProcessMouseSelection(Point mousePosition, GridCellElement currentCell)
{
if (this.RootGridBehavior.LockedBehavior != this)
{
this.GridControl.Capture = true;
this.RootGridBehavior.LockBehavior(this);
}
GridCellElement mouseDownCell = this.GetCellAtPoint(this.MouseDownLocation);
GridCellElement oldCurrentCell = this.GetCellAtPoint(this.oldCurrentLocation);
bool isValidResizingContext = this.ResizeSelectionRectangle(currentCell, mousePosition);
bool result = false;
if (isValidResizingContext && oldCurrentCell != currentCell)
{
if (this.MasterTemplate.MultiSelect && !this.GridViewElement.Template.AllowRowReorder)
{
if (this.MasterTemplate.SelectionMode == GridViewSelectionMode.FullRowSelect)
{
bool selectedRowsChanged = false;
bool isPressedShiftOrControl = (this.IsPressedShift || this.IsPressedControl);
GridTableElement tableElement = this.GridViewElement.CurrentView as GridTableElement;
RadElementCollection scrollableRows = tableElement.ViewElement.ScrollableRows.Children;
RadElementCollection topPinnedRows = tableElement.ViewElement.TopPinnedRows.Children;
RadElementCollection bottomPinnedRows = tableElement.ViewElement.BottomPinnedRows.Children;
GridViewRowInfo[] selectedRows = this.MasterTemplate.SelectedRows.ToArray();
tableElement.BeginUpdate();
int oldSelectedRows = this.MasterTemplate.SelectedRows.Count;
if (!isPressedShiftOrControl)
{
for (int i = selectedRows.Length - 1; i >= 0; i--)
{
GridViewRowInfo rowInfo = selectedRows[i];
GridRowElement rowElement = tableElement.GetRowElement(rowInfo);
bool select = rowElement != null &&
rowElement.ControlBoundingRectangle.IntersectsWith(this.GridViewElement.SelectionRectangle);
if (select)
{
rowInfo.IsSelected = true;
}
if (!rowInfo.IsSelected)
{
selectedRowsChanged = true;
}
}
}
selectedRowsChanged = this.SelectIntersectedRows(topPinnedRows);
selectedRowsChanged |= this.SelectIntersectedRows(scrollableRows);
selectedRowsChanged |= this.SelectIntersectedRows(bottomPinnedRows);
if (oldSelectedRows != this.MasterTemplate.SelectedRows.Count)
{
selectedRowsChanged = true;
}
tableElement.EndUpdate(false);
}
else
{
GridTableElement tableElement = this.GridViewElement.CurrentView as GridTableElement;
if (tableElement == null)
{
return result;
}
CancelEventArgs cancelArgs = new CancelEventArgs();
this.MasterTemplate.EventDispatcher.RaiseEvent<CancelEventArgs>(EventDispatcher.SelectionChanging, this, cancelArgs);
if (cancelArgs.Cancel)
{
return result;
}
//Since version Q2 2014 (version 2014.2.617), please use:
//GridViewSelectionCancelEventArgs cancelArgs = new GridViewSelectionCancelEventArgs(this.MasterTemplate.CurrentRow, this.MasterTemplate.CurrentColumn);
//this.MasterTemplate.EventDispatcher.RaiseEvent<GridViewSelectionCancelEventArgs>(EventDispatcher.SelectionChanging, this, cancelArgs);
//if (cancelArgs.Cancel)
//{
// return result;
//}
this.GridViewElement.CurrentView.BeginUpdate();
bool isProcessedShiftOrControl = (this.IsPressedShift || this.IsPressedControl);
int count = this.MasterTemplate.SelectedCells.Count;
RadElementCollection scrollableRows = tableElement.ViewElement.ScrollableRows.Children;
RadElementCollection topPinnedRows = tableElement.ViewElement.TopPinnedRows.Children;
RadElementCollection bottomPinnedRows = tableElement.ViewElement.BottomPinnedRows.Children;
this.SelectIntersectedCells(scrollableRows, isProcessedShiftOrControl);
this.SelectIntersectedCells(topPinnedRows, isProcessedShiftOrControl);
this.SelectIntersectedCells(bottomPinnedRows, isProcessedShiftOrControl);
bool notifyUpdates = true;
if (isProcessedShiftOrControl)
{
notifyUpdates = count != this.MasterTemplate.SelectedCells.Count;
}
this.GridViewElement.CurrentView.EndUpdate(false);
this.GridViewElement.Invalidate();
}
result = true;
}
result = false;
}
this.oldCurrentLocation = mousePosition;
return result;
}
}
Register the new behavior as follows:
BaseGridBehavior behavior = (BaseGridBehavior)this.radGridView1.GridBehavior;
behavior.UnregisterBehavior(typeof(GridViewDataRowInfo));
behavior.RegisterBehavior(typeof(GridViewDataRowInfo), new MyGridRowBehavior());
Allow drag and drop of rows, when RadGridView is in bound mode. Please refer to the following article demonstrating how to do that: http://www.telerik.com/help/winforms/gridview-rows-drag-and-drop.html