How to reproduce: public partial class Form1 : Form { public Form1() { InitializeComponent(); GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn(); decimalColumn.Name = "DecimalColumn"; decimalColumn.HeaderText = "DecimalColumn"; this.radGridView1.MasterTemplate.Columns.Add(decimalColumn); GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn(); textBoxColumn.Name = "TextBoxColumn"; textBoxColumn.HeaderText = "TextBoxColumn"; this.radGridView1.MasterTemplate.Columns.Add(textBoxColumn); GridViewDateTimeColumn dateTimeColumn = new GridViewDateTimeColumn(); dateTimeColumn.Name = "DateTimeColumn"; dateTimeColumn.HeaderText = "DateTimeColumn"; this.radGridView1.MasterTemplate.Columns.Add(dateTimeColumn); } } Workaround: this.radGridView1.MasterView.TableAddNewRow.MinHeight = 30;
When the EnableHeaderCheckBox property is set to true, whenever the checkbox is clicked in the new row, a new row is actually added to the grid before any other modifications are made. This can be replicated in the attached sample project. Run it and click the checkbox in the new row several times. Multiple rows are added. Workaround: cancel the RadGridView.UserAddingRow until all the required fields are filled.
To reproduce: public Form1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Id"); dt.Columns.Add("Name"); for (int i = 0; i < 1; i++) { dt.Rows.Add(i, "Item"); } this.radGridView1.DataSource = dt; this.radGridView1.SelectionMode = GridViewSelectionMode.FullRowSelect; this.radGridView1.ClipboardCopyMode = Telerik.WinControls.UI.GridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText; this.radGridView1.MultiSelect = true; } private void button1_Click(object sender, EventArgs e) { this.radGridView1.SelectAll(); this.radGridView1.Copy(); } If you click the button, you will notice that only one cell is copied. However, if you add 2 and more rows, the whole grid content will be copied to the clipboard. Workaround: use the BeginRowCopy/EndRowCopy methods. private void button1_Click(object sender, EventArgs e) { this.radGridView1.SelectAll(); this.radGridView1.MasterTemplate.BeginRowCopy(); this.radGridView1.Copy(); this.radGridView1.MasterTemplate.EndRowCopy(); }
To reproduce: - Add several columns including combo-box columns to a grid. - Add one row and upon a button click, change the data source of the combo column. Workaround: Seth the following field to null prior changing the data source: GetType(GridViewComboBoxColumn).GetField("nullBoundItem", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).SetValue(combo, Nothing) combo.DataSource = dt
To reproduce: add a RadGridView and a RadButton on the form. Use the following code snippet: public RadForm1() { InitializeComponent(); this.radGridView1.Columns.Add("Col1"); this.radGridView1.Columns.Add("Col2"); for (int i = 0; i < 5; i++) { this.radGridView1.Rows.Add(i, "Item" + i); } this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.RowValidating += radGridView1_RowValidating; this.radGridView1.UserAddingRow += radGridView1_UserAddingRow; } private void radGridView1_UserAddingRow(object sender, Telerik.WinControls.UI.GridViewRowCancelEventArgs e) { e.Cancel = true; } private void radGridView1_RowValidating(object sender, Telerik.WinControls.UI.RowValidatingEventArgs e) { if (e.Row.IsModified && e.Row is GridViewDataRowInfo) { e.Cancel = true; } } private void radButton1_Click(object sender, EventArgs e) { RadMessageBox.Show("Clicked"); } 1. Select a data cell and activate the editor. Enter some new value and click the button. The Click event is fired. 2. Select the new row and activate the editor. Enter some value and click the button. The Click event is NOT fired. Workaround: use the CellValidating event instead.
To reproduce: Sub New() InitializeComponent() Dim dt1 As New DataTable dt1.Columns.Add("Id", GetType(Integer)) dt1.Columns.Add("Name", GetType(String)) For index = 1 To 20 dt1.Rows.Add(index, "Parent" & index) Next Me.RadGridView1.MasterTemplate.DataSource = dt1 Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill Dim dt2 As New DataTable dt2.Columns.Add("Id", GetType(Integer)) dt2.Columns.Add("Name", GetType(String)) dt2.Columns.Add("ParentId", GetType(Integer)) Dim dt3 As New DataTable dt3.Columns.Add("Id", GetType(Integer)) dt3.Columns.Add("Name", GetType(String)) dt3.Columns.Add("ParentId", GetType(Integer)) For index = 1 To 20 If index Mod 2 = 0 Then dt2.Rows.Add(index, "Child1." & index, index) If index Mod 4 = 0 Then dt3.Rows.Add(index, "Child2." & index, index) End If ElseIf index Mod 3 = 0 Then dt3.Rows.Add(index, "Child2." & index, index) Else dt3.Rows.Add(index, "Child2." & index, index) End If Next Dim template As New GridViewTemplate() template.DataSource = dt2 template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill RadGridView1.MasterTemplate.Templates.Add(template) Dim relation As New GridViewRelation(RadGridView1.MasterTemplate) relation.ChildTemplate = template relation.RelationName = "FirstChild" relation.ParentColumnNames.Add("Id") relation.ChildColumnNames.Add("ParentId") RadGridView1.Relations.Add(relation) Dim template2 As New GridViewTemplate() template2.DataSource = dt3 template2.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill RadGridView1.MasterTemplate.Templates.Add(template2) Dim relation2 As New GridViewRelation(RadGridView1.MasterTemplate) relation2.ChildTemplate = template2 relation2.RelationName = "SecondChild" relation2.ParentColumnNames.Add("Id") relation2.ChildColumnNames.Add("ParentId") RadGridView1.Relations.Add(relation2) AddHandler Me.RadGridView1.ChildViewExpanding, AddressOf ChildViewExpanding End Sub Private Sub RadGridView1_ViewCellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) _ Handles RadGridView1.ViewCellFormatting Dim cell As GridDetailViewCellElement = TryCast(e.CellElement, GridDetailViewCellElement) Dim expanderCell As GridGroupExpanderCellElement = TryCast(e.CellElement, GridGroupExpanderCellElement) If expanderCell IsNot Nothing AndAlso TypeOf e.CellElement.RowElement Is GridDataRowElement Then Dim hierarchyRow As GridViewHierarchyRowInfo = DirectCast(expanderCell.RowInfo, GridViewHierarchyRowInfo) If Not IsExpandable(hierarchyRow) Then expanderCell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Hidden Else expanderCell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Visible End If ElseIf cell IsNot Nothing Then Dim hierarchyRow As GridViewHierarchyRowInfo = DirectCast(DirectCast(cell.RowInfo, GridViewDetailsRowInfo).Owner, _ GridViewHierarchyRowInfo) For i As Integer = 0 To cell.PageViewElement.Items.Count - 1 Dim item As RadPageViewItem = cell.PageViewElement.Items(i) Dim viewInfo As GridViewInfo = hierarchyRow.Views(i) item.Text = "Child Template " & i If viewInfo.ChildRows.Count = 0 Then If i = 0 AndAlso i < cell.PageViewElement.Items.Count - 1 Then cell.PageViewElement.Items(i + 1).IsSelected = True End If item.Visibility = Telerik.WinControls.ElementVisibility.Hidden Else item.Visibility = Telerik.WinControls.ElementVisibility.Visible End If Next End If End Sub Private Function IsExpandable(hierarchyRow As GridViewHierarchyRowInfo) As Boolean For Each view As GridViewInfo In hierarchyRow.Views If view.ChildRows.Count > 0 Then Return True End If Next Return False End Function Workaround: AddHandler Me.RadGridView1.ChildViewExpanding, AddressOf RadGridView1_ChildViewExpanding AddHandler Me.RadGridView1.MouseDown, AddressOf RadGridView_MouseDown Private Sub RadGridView1_ChildViewExpanding(sender As Object, e As ChildViewExpandingEventArgs) If lastClicked IsNot Nothing AndAlso e.ParentRow.Equals(lastClicked) Then e.Cancel = False Else e.Cancel = True End If End Sub Dim lastClicked As GridViewRowInfo Private Sub RadGridView_MouseDown(sender As Object, e As MouseEventArgs) Dim expander As GridExpanderItem = TryCast(Me.RadGridView1.ElementTree.GetElementAtPoint(e.Location), GridExpanderItem) If expander IsNot Nothing Then lastClicked = DirectCast(expander.Parent, GridGroupExpanderCellElement).RowInfo End If End Sub
To reproduce: - Add GridViewTextBoxColumn and set the MaxLength property. - Paste in data row while the is not in edit mode. Workaround: private void RadGridView1_Pasting(object sender, Telerik.WinControls.UI.GridViewClipboardEventArgs e) { if (radGridView1.CurrentColumn.Name == "column1") { GridViewTextBoxColumn col = new GridViewTextBoxColumn(); var lenght = col.MaxLength; if (Clipboard.ContainsData(DataFormats.Text)) { e.Cancel = true; string data = Clipboard.GetData(DataFormats.Text).ToString(); radGridView1.CurrentCell.Value = data.Substring(0, lenght); } } }
Steps to reproduce: 1. Add a CompositeFilterDescriptor programmatically as it is demonstrated in the following help article: http://docs.telerik.com/devtools/winforms/gridview/filtering/setting-filters-programmatically-(composite-descriptors) 2. Save the layout. 3. Load the layout. Workaround: specify the PropertyName property for the CompositeFilterDescriptor.
To reproduce: Sub New() InitializeComponent() Dim dt As New DataTable dt.Columns.Add("Id", GetType(Integer)) dt.Columns.Add("Name", GetType(String)) dt.Columns.Add("Description", GetType(String)) For index = 1 To 5 dt.Rows.Add(index, "Item" & index, "Description" & index) Next Me.RadGridView1.DataSource = dt Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill AddHandler Me.RadGridView1.UserAddingRow, AddressOf UserAddingRow End Sub Private Sub UserAddingRow(sender As Object, e As Telerik.WinControls.UI.GridViewRowCancelEventArgs) Me.RadGridView1.MasterView.TableAddNewRow.ErrorText = "" If String.IsNullOrEmpty(e.Rows(0).Cells(0).Value) Then e.Cancel = True Me.RadGridView1.MasterView.TableAddNewRow.ErrorText = "Empty value is not allowed!" End If End Sub 1. Click the new row and enter a value in the last cell. 2. Click outside the new row, e.g. click on a data row. The UserAddingRow event is canceled and the new row remains current. 3. Click a data row again without any modification on the new row. The new row is not current anymore. 4. However, you perform step 1and 2 but instead of clicking a data row, the user clicks a header cell, the new row is not current from the first time. It is necessary to forbid the user to exit the new row until the validation passes or the new row is canceled by pressing Enter. Workaround: use the CellValidating/RowValidating event for validating.
Consider the case where there are many child views and you want to export only the ones that actually contain data. Currently, you can either export only one view or all. One should be able to pass all the views in the ChildViewExporting event.
Workaround: create a custom GridDetailViewCellElement Public Class Form1 Sub New() InitializeComponent() AddHandler dgvPatients.CreateCell, AddressOf dgvPatients_CreateCell End Sub Private Sub dgvPatients_CreateCell(sender As Object, e As GridViewCreateCellEventArgs) If e.CellType = GetType(GridDetailViewCellElement) Then e.CellElement = New MyGridDetailViewCellElement(e.Column, e.Row) End If End Sub End Class Public Class MyGridDetailViewCellElement Inherits GridDetailViewCellElement Sub New(column As GridViewColumn, rowElement As GridRowElement) MyBase.New(column, rowElement) End Sub Public Overrides Sub UpdateTabItemsVisibility() If Me.DetailsRow Is Nothing Then Return End If MyBase.UpdateTabItemsVisibility() End Sub End Class
To reproduce: GridViewTextBoxColumn textBoxColumn1 = new GridViewTextBoxColumn("Col 1"); textBoxColumn1.FieldName = "col1"; radGridView1.MasterTemplate.Columns.Add(textBoxColumn1); GridViewTextBoxColumn textBoxColumn2 = new GridViewTextBoxColumn("Col 2"); textBoxColumn2.FieldName = "col2"; textBoxColumn2.FormatString = "{0:d}"; radGridView1.MasterTemplate.Columns.Add(textBoxColumn2); radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; DataTable dt = new DataTable(); dt.Columns.Add("col1", typeof(string)); dt.Columns.Add("col2", typeof(DateTime)); for (int i = 0; i < 10; i++) { dt.Rows.Add("Item" + i, DateTime.Now.AddDays(i)); } this.radGridView1.AutoGenerateColumns = false; this.radGridView1.DataSource = dt; Right click the row header cell and select Copy. The following exception occurs although we don't have a GridViewDateTimeColumn : System.InvalidCastException was unhandled HResult=-2147467262 Message=Unable to cast object of type 'Telerik.WinControls.UI.GridViewTextBoxColumn' to type 'Telerik.WinControls.UI.GridViewDateTimeColumn'. Source=Telerik.WinControls.GridView StackTrace: at Telerik.WinControls.UI.MasterGridViewTemplate.CopyRows(String format, Boolean cut, Boolean cutOperation, StringBuilder content) at Telerik.WinControls.UI.MasterGridViewTemplate.ProcessContent(String format, Boolean cut, Boolean cutOperation) at Telerik.WinControls.UI.MasterGridViewTemplate.CopyContent(Boolean cut) at Telerik.WinControls.UI.MasterGridViewTemplate.Copy() at Telerik.WinControls.UI.GridDataRowElement.copyItem_Click(Object sender, EventArgs e) at Telerik.WinControls.RadElement.OnClick(EventArgs e) at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e) at Telerik.WinControls.UI.RadMenuItem.OnClick(EventArgs e) at Telerik.WinControls.RadElement.DoClick(EventArgs e) at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e) at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e) at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at Telerik.WinControls.RadControl.WndProc(Message& m) at Telerik.WinControls.UI.RadPopupControlBase.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at _1075342CopyText.Program.Main() in d:\Projects\1075342CopyText_Binding\Program.cs:line 17 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: Workaround: use a GridViewDateTimeColumn
The problematic themes are: Aqua HighContrastBlack VisualStudio2012Dark VisualStudio2012Light Windows8 How to reproduce: private void RadForm1_Load(object sender, EventArgs e) { var theme = new Windows8Theme(); ThemeResolutionService.ApplicationThemeName = "Windows8"; GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn(); textBoxColumn.Name = "Test"; this.radGridView1.Columns.Add(textBoxColumn); for (int i = 0; i < 100; i++) { this.radGridView1.Rows.AddNew(); } } Workaround: private void RadForm1_Load(object sender, EventArgs e) { var theme = new Windows8Theme(); ThemeResolutionService.ApplicationThemeName = "Windows8"; GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn(); textBoxColumn.Name = "Test"; this.radGridView1.Columns.Add(textBoxColumn); this.radGridView1.BeginUpdate(); for (int i = 0; i < 100; i++) { this.radGridView1.Rows.AddNew(); } this.radGridView1.EndUpdate(); int lastRow = this.radGridView1.Rows.Count - 1; this.radGridView1.Rows[lastRow].IsCurrent = true; }
Please refer to the attached sample project and select a new value in the drop down. Workaround: change the PageSize in the RadDropDownListElement.PopupClosed event: public sealed class PageSizeDropdownHeaderCellElement : GridHeaderCellElement { public PageSizeDropdownHeaderCellElement(GridViewColumn col, GridRowElement row) : base(col, row) { TextAlignment = ContentAlignment.TopCenter; Alignment = ContentAlignment.TopCenter; } private RadDropDownListElement _dropDownListElement; protected override void CreateChildElements() { base.CreateChildElements(); _dropDownListElement = new RadDropDownListElement(); if (_dropDownListElement != null && _dropDownListElement.DataSource == null) { _dropDownListElement = new RadDropDownListElement(); _dropDownListElement.BindingContext = new BindingContext(); _dropDownListElement.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList; _dropDownListElement.Items.Clear(); _dropDownListElement.Items.Add(new RadListDataItem("10", 10) { Selected = true }); _dropDownListElement.Items.Add(new RadListDataItem("25", 25)); _dropDownListElement.Items.Add(new RadListDataItem("50", 50)); _dropDownListElement.Items.Add(new RadListDataItem("100", 100)); _dropDownListElement.Items.Add(new RadListDataItem("All", -1)); _dropDownListElement.Margin = new Padding(15, 0, 0, 0); _dropDownListElement.StretchHorizontally = true; _dropDownListElement.NotifyParentOnMouseInput = false; _dropDownListElement.Popup.MouseClick += Popup_MouseClick; _dropDownListElement.PopupClosed += _dropDownListElement_PopupClosed; this.Children.Add(_dropDownListElement); } } RadListVisualItem elementUnderMouse; private void Popup_MouseClick(object sender, MouseEventArgs e) { elementUnderMouse = _dropDownListElement.Popup.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem; } private void _dropDownListElement_PopupClosed(object sender, RadPopupClosedEventArgs args) { if (elementUnderMouse == null) { return; } if (_dropDownListElement.SelectedIndex == -1) return; var pageSize = Convert.ToInt32(elementUnderMouse.Data.Value); if (pageSize == -1) { pageSize = GridControl.RowCount; } else { pageSize = pageSize <= GridControl.RowCount ? pageSize : GridControl.RowCount; } this.RowInfo.Tag = pageSize; GridControl.PageSize = pageSize; elementUnderMouse = null; } protected override void SetContentCore(object value) { if (_dropDownListElement != null && this.RowInfo.Tag != null) { this._dropDownListElement.SelectedValue = (int)this.RowInfo.Tag; } } public override bool IsCompatible(GridViewColumn data, object context) { return data is ActionColumn && context is GridTableHeaderRowElement; } protected override Type ThemeEffectiveType { get { return typeof(GridHeaderCellElement); } } }
To reproduce: - Subscribe to the CellClick event - Click several times in the grid with the right mouse button. - At some point, the CellClick event will be executed. Workaround: - Use the Click event: private void RadGridView1_Click(object sender, EventArgs e) { var args = e as MouseEventArgs; if (args.Button == MouseButtons.Left) { var clickedCell = radGridView1.ElementTree.GetElementAtPoint(args.Location) as GridDataCellElement; if (clickedCell != null) { //add your code here } } }
To reproduce: - Add one-to-many relations hierarchy 3 or more child templates. - Export the grid using GridViewSpreadExport - The child rows of the last parent row are missing. Workaround: Add an empty parent row at the end of the grid.
To reproduce: - Bind the grid to an object that contains enum property. - Save the layout - Restart the application and load the layout before setting the DataSource of the grid. Workaround: Load the layout after the DataSource is set.
Description: if you filter a text column with "Does not contains" operator, the produced FilterDescriptors.Expression is "ProductName NOT LIKE '%c%' OR ProductName IS NULL". However, if you try to programmatically add this expression to the RadGridView.FilterDescriptors.Expression property it doesn't filter the grid. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products) Me.RadGridView1.EnableFiltering = True End Sub Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Me.RadGridView1.FilterDescriptors.Expression = "ProductName NOT LIKE '%c%' OR ProductName IS NULL" End Sub Workaround: don't set expression but add a FilterDescriptor: http://docs.telerik.com/devtools/winforms/gridview/filtering/setting-filters-programmatically-(simple-descriptors) Dim filter1 As New FilterDescriptor() filter1.[Operator] = FilterOperator.NotContains filter1.Value = "c" filter1.IsFilterEditor = True filter1.PropertyName = "ProductName" Me.RadGridView1.FilterDescriptors.Add(filter1)
Workaround: create a custom RadListFilterPopup private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e) { e.FilterPopup = new MyRadListFilterPopup(e.Column); } public class MyRadListFilterPopup : RadListFilterPopup { public MyRadListFilterPopup(GridViewDataColumn dataColumn) : base(dataColumn, false) { } protected override RadListFilterDistinctValuesTable GetDistinctValuesTable() { if (this.DataColumn.OwnerTemplate.HierarchyLevel == 0) { return base.GetDistinctValuesTable(); } GridViewColumnValuesCollection distinctValues = this.GetDistinctValuesWithFilter(this.DataColumn); RadListFilterDistinctValuesTable valuesTable = new RadListFilterDistinctValuesTable(); valuesTable.FormatString = this.DataColumn.FormatString; valuesTable.DataConversionInfoProvider = this.DataColumn; GridViewComboBoxColumn comboBoxColumn = this.DataColumn as GridViewComboBoxColumn; if (comboBoxColumn != null && !String.IsNullOrEmpty(comboBoxColumn.ValueMember)) { foreach (object value in distinctValues) { if (value != null && value != System.DBNull.Value) { object rowValue = value; object lookupValue = ((GridViewComboBoxColumn)this.DataColumn).GetLookupValue(value); if (comboBoxColumn.FilteringMode == GridViewFilteringMode.DisplayMember) { rowValue = lookupValue; } if (lookupValue != null) { valuesTable.Add(lookupValue.ToString(), rowValue); } } } } else { foreach (object value in distinctValues) { valuesTable.Add(value); } } return valuesTable; } private GridViewColumnValuesCollection GetDistinctValuesWithFilter(GridViewDataColumn column) { GridViewColumnValuesCollection distinctValues = new GridViewColumnValuesCollection(); int count = column.OwnerTemplate.ExcelFilteredColumns.Count; if ((count > 0 && column == column.OwnerTemplate.ExcelFilteredColumns[count - 1]) || column.OwnerTemplate.HierarchyLevel > 0) { if (count == 1 || column.OwnerTemplate.HierarchyLevel > 0) { int index = column.Index; if (index >= 0) { IList<GridViewRowInfo> templateRows = column.OwnerTemplate.Rows; if (templateRows.Count == 0 && column.OwnerTemplate.Parent != null && column.OwnerTemplate.HierarchyLevel > 0) { templateRows = new List<GridViewRowInfo>(); GridViewInfo templateViewInfo = column.OwnerTemplate.MasterViewInfo; for (int i = 0; i < column.OwnerTemplate.Parent.Rows.Count; i++) { GridViewRowInfo parentRow = column.OwnerTemplate.Parent.Rows[i]; ((List<GridViewRowInfo>)templateRows).AddRange(column.OwnerTemplate.HierarchyDataProvider.GetChildRows(parentRow, templateViewInfo)); } } foreach (GridViewRowInfo row in templateRows) { object cellValue = row.Cells[index].Value; if (!distinctValues.Contains(cellValue)) { distinctValues.Add(cellValue); } } if (distinctValues.Count > 0) { return distinctValues; } } } } return distinctValues; } }