Add support for the GridViewComboBoxColumn to initialize properly when the BindingList it is bound to is empty.
To reproduce :
Create a self-referencing hierarchy, bind it to a BindingList and delete the row with either the delete button or from the context menu and click the deleted item.
Workaround :
Find the object that has to be deleted, hide the selected row and remove the found object from the data source.
void radGridView1_UserDeletingRow(object sender, GridViewRowCancelEventArgs e)
{
e.Cancel = true;
int id = int.Parse(e.Rows[0].Cells["Id"].Value.ToString());
var human = this.humans.FirstOrDefault(x => x.Id == id);
if (human != null)
{
this.radGridView1.SelectedRows[0].IsVisible = false;
this.humans.Remove(human);
}
}
To reproduce: Dim dockmem As New MemoryStream
Dim gridmem As New MemoryStream
Public Sub SetData()
' dgvSelectList.DataSource = Nothing
Dim dt As DataTable
dt = New DataTable
dt.Columns.Add("VENDCODE")
dt.Columns.Add("VENDNAME")
dt.Rows.Add("AA2", "Arthur")
dt.Rows.Add("AA2", "Arthur")
dgvSelectList.DataSource = dt
dgvSelectList.BestFitColumns()
End Sub
Private Sub frmSelectListNG2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
SetData()
dgvSelectList.EnableFiltering = False
'Save Grid and Dock layout settings to mem stream and simulate my process
SaveSettings()
End Sub
Public Sub btnGO_Click(sender As System.Object, e As System.EventArgs) Handles btnGO.Click
LoadSettings()
dgvSelectList.SplitMode = RadGridViewSplitMode.Horizontal
SetData()
LoadSettings()
End Sub
Private Sub LoadSettings()
gridmem.Position = 0
dockmem.Position = 0
dgvSelectList.LoadLayout(gridmem)
rdkSelect.LoadFromXml(dockmem)
End Sub
Private Sub SaveSettings()
gridmem.Position = 0
dockmem.Position = 0
dgvSelectList.SaveLayout(gridmem)
rdkSelect.SaveToXml(dockmem)
End Sub
Workaround - set the datasource to Nothing prior rebinding
To reproduce:
radGridView1 = new RadGridView();
radGridView1.Dock = DockStyle.Fill;
Controls.Add(radGridView1);
t.Columns.Add("ID");
t.Rows.Add(7);
t.Rows.Add(5);
t.Rows.Add(8);
t.Rows.Add(4);
t.Rows.Add(9);
radGridView1.DataSource = t;
radGridView1.Columns[0].Width = 100;
With the code above, start the app, sort the grid ascending and select the row with value 8. Use the following code on a button to delete the row with value 5:
private void radButton1_Click(object sender, EventArgs e)
{
t.Rows[1].Delete();
}
In this case, the current should be the row with value 8, not the one with value 7 as is.
To reproduce:
- Create a grid with ColumnGroupsViewDefinition view( Column Groups View)
- Set the AutoSizeColumnsMode to fill
- Start the project and resize a column
- Resize a column then minimize and maximize
- The column have a different size
Workaround:
-Handle the form layout event like this:
void Form1_Layout(object sender, LayoutEventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.radGridView1.GridElement.SuspendLayout();
}
else
{
this.radGridView1.GridElement.ResumeLayout(true);
}
}
To reproduce:
public Form1()
{
InitializeComponent();
Random r = new Random();
DataTable table = new DataTable("table1");
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Bool", typeof(bool));
table.Columns.Add("DateColumn", typeof(DateTime));
for (int i = 0; i < 10; i++)
{
table.Rows.Add(i, "Row " + i, r.Next(10) > 5 ? true : false, DateTime.Now.AddHours(i));
}
DataSet dataSet = new DataSet();
dataSet.Tables.Add(table);
radGridView1.DataBindingComplete += radGridView1_DataBindingComplete;
this.radGridView1.DataSource = dataSet;
this.radGridView1.DataMember = "table1";
}
void radGridView1_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e)
{
}
To reproduce:
-set AutoSizeMode to Fill
- Add view definition with two rows
- Add check box column to the view
-Set check box column minWidth
Workaround:
Create a custom view definition, then create a custom ColumnGroupRowLayout class and override the GetClumnWidth method like this:
class MyViewDefinition : ColumnGroupsViewDefinition
{
public MyViewDefinition()
{
}
public override IGridRowLayout CreateRowLayout()
{
return new MyRowLayout(this);
}
}
public class MyRowLayout : ColumnGroupRowLayout
{
public MyRowLayout(ColumnGroupsViewDefinition view):base(view)
{
}
public override int GetColumnWidth(GridViewColumn column)
{
return Math.Max( base.GetColumnWidth(column), column.MinWidth);
}
}
To reproduce Switch to Right-to-Left mode. Look at the top left corner of the grid. Workaround this.radGridView1.TableElement.Children[0].Margin = new Padding(-2, 0, 0, 0);
IMPROVE. RadGridView - when sorting grouped combo box column the DisplayMemberSort is not taken into consideration
Steps to reproduce: 1. Add a grid with several columns, so there is horizontal scroll bar 2. Add an image to the grid ImageList 3. In the CellFormatting assign the ImageKey of a cell to a value You will notice that the images are not applied initially. You have to scroll the column where you apply the images out of view and bring it back in to see the images. WORKAROUND Instead of setting the ImageKey property, set the Image property to the corresponding image from the image list.
Workaround: Use a custom editor and override IsModified method:
class MyEditor : RadDropDownListEditor
{
public override bool IsModified
{
get
{
return true;
}
}
}
void radGridViewFilter_EditorRequired(object sender, EditorRequiredEventArgs e)
{
if (e.EditorType == typeof(RadDropDownListEditor)) { e.Editor = new MyEditor();
}
}
RadGridView.- HierarchyDataProvider property of the GridViewTemplate should be set after the GridViewTemplate is added to Templates Collection.
When a mask is set to a GridViewMaskBoxColumn and string is applied as value, the visual element will show only the string without the mask literals. E.g. mask is set to ####/# and value is set to string "11112" the view will be 11112 instead of 1111/2. Ways to achieve this: 1. Use CellFormatting. 2. Use a custom type converter: Example of a custom TypeConverter could be seen from the following feedback item: http://feedback.telerik.com/Project/154/Feedback/Details/112463-fix-radgridview-the-textmaskformat-property-of-gridviewmaskboxcolumn-is-not-ta
Steps to reproduce: 1. Add three rows to a grid 2. Filter one through CustomFiltering 3. Run the project and apply a filter that will filter one of the remaining two rows 4. Now delete the filter value. You will see that the second row will not be visible although there is no filter. WORKAROUND Clear the filter on the column when the user deletes the value of the filter: private void radGridView1_ValueChanging(object sender, ValueChangingEventArgs e) { if (this.radGridView1.CurrentColumn.Name == "ColumnName" && Convert.ToString(e.NewValue) == String.Empty) { int i = 0; while (i < this.radGridView1.FilterDescriptors.Count) { if (this.radGridView1.FilterDescriptors[i].PropertyName == "ColumnName") { this.radGridView1.FilterDescriptors.RemoveAt(i); continue; } i++; } } }
RadGridView - You cannot select cells only from Pinned Columns if under them there is unpinned one. Steps to reproduce: 1. Set SelectionMode property of RadGridView to GridViewSelectionMode.CellSelect. 2. Create 3 left pinned columns 3. Create several unpinned columns. 4. Scroll horizontal scroll bar to hide several unpinned columns under the pinned. 5. Try to select only pinned cells with the selection rectangle.
In RadGridView with a TextBoxColumn.
Set WrapText, Multiline and AcceptsReturn to true
If adding a new line, the return gives another new line instead of staying within the cell.
Workaround:
Create a new behavior class:
//VB
Class MyNewRowBehavior
Inherits GridNewRowBehavior
Protected Overrides Function ProcessEnterKey(keys As KeyEventArgs) As Boolean
If Me.GridControl.IsInEditMode AndAlso Me.GridControl.CurrentColumn.Name = "TextBoxColumn" Then
Dim editor As RadTextBoxEditor = TryCast(Me.GridControl.ActiveEditor, RadTextBoxEditor)
Dim element As RadTextBoxEditorElement = DirectCast(editor.EditorElement, RadTextBoxEditorElement)
element.Text.Insert(element.Text.Length, Environment.NewLine)
Return True
Else
Return MyBase.ProcessEnterKey(keys)
End If
End Function
End Class
//C#
class MyNewRowBehavior : GridNewRowBehavior
{
protected override bool ProcessEnterKey(KeyEventArgs keys)
{
if (this.GridControl.IsInEditMode && this.GridControl.CurrentColumn.Name == "TextBoxColumn")
{
RadTextBoxEditor editor = this.GridControl.ActiveEditor as RadTextBoxEditor;
RadTextBoxEditorElement element = (RadTextBoxEditorElement)editor.EditorElement;
element.Text.Insert(element.Text.Length, Environment.NewLine);
return true;
}
else
{
return base.ProcessEnterKey(keys);
}
}
}
then unregister the old behavior and register the new one:
//VB
DirectCast(radGridView1.GridBehavior, BaseGridBehavior).UnregisterBehavior(GetType(GridViewNewRowInfo))
DirectCast(radGridView1.GridBehavior, BaseGridBehavior).RegisterBehavior(GetType(GridViewNewRowInfo), New MyNewRowBehavior())
//C#
((BaseGridBehavior)radGridView1.GridBehavior).UnregisterBehavior(typeof(GridViewNewRowInfo));
((BaseGridBehavior)radGridView1.GridBehavior).RegisterBehavior(typeof(GridViewNewRowInfo), new MyNewRowBehavior());
Workaround, use the following behavior:
public class CustomDataRowBehavior : GridDataRowBehavior
{
protected override bool OnMouseDownRight(MouseEventArgs e)
{
if (this.IsInEditMode && !this.GridViewElement.EndEdit())
RadGridView - CustomGrouping event is not firing when you change some cell value and RadGridView is data bound via DataSource property.
Workaround:
1.Subscribe to CellEndEdit event of RadGridView:
this.radGridView1.CellEndEdit += new GridViewCellEventHandler(radGridView1_CellEndEdit);
2. Call Refresh method of MasterTemplate:
void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
{
this.radGridView1.MasterTemplate.Refresh();
}
To reproduce:
- Add a checkbox column to a grid
- Add the following code to the ValueChanged event:
void radGridView1_ValueChanged(object sender, EventArgs e)
{
if (radGridView1.CurrentColumn.Name == "BoolColumn")
{
Steps to reproduce: 1. Add a combobox column to a grid 2. Set DisplayMember, ValueMember and a data source to the column 3. Change a property in the data source that is used as value in the combo column You will see that the combo column will not display text for the item which value was changed