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;
}
To reproduce:
- Bind the grid to a data source and set its RightToLeftProperty to true.
Note: use Visual Studio 2008 under Windows XP with .NET 2.0
Workaround:
Private Sub RadGridView1_ViewCellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs)
If RadGridView1.RightToLeft = Windows.Forms.RightToLeft.Yes Then
e.CellElement.TextAlignment = ContentAlignment.MiddleLeft
End If
End Sub
i would like to customize the grid like below attached screen shot,is it possible using telerik win forms (rad grid view), if possible can you please send me sample code for that, if not possible can you suggest me alternate solution for this requirement.
To reproduce:
public Form1()
{
InitializeComponent();
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].Columns.Add(this.radGridView1.Columns["CompanyName"]);
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ContactName"]);
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ContactTitle"]);
view.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Address"]);
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["City"]);
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Country"]);
view.ColumnGroups[1].Groups[1].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Phone"]);
view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Fax"]);
radGridView1.ViewDefinition = view;
radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
view.ColumnGroups[0].PinPosition = PinnedColumnPosition.Left;
}
Please see the attached screenshot.
Workaround: add the columns belonging to the pinned group in a reversed order.
To reproduce, use this code:
AddGrid();
List<DropDownObject> lstDrp = new List<DropDownObject>();
DropDownObject drpObj = new DropDownObject();
drpObj.DropdownValue = "100";
drpObj.DropdownValueID = 1;
DropDownObject drpObj2 = new DropDownObject();
drpObj2.DropdownValue = "100";
drpObj2.DropdownValueID = 2;
DropDownObject drpObj1 = new DropDownObject();
drpObj1.DropdownValue = "101";
drpObj1.DropdownValueID = 1;
lstDrp.Add(drpObj);
lstDrp.Add(drpObj2);
lstDrp.Add(drpObj1);
DataTable dtMain = new DataTable();
DataColumn dcDropCol = new DataColumn();
dcDropCol.ColumnName = "DropDown Col";
dcDropCol.DataType = typeof(System.Int32);
dtMain.Columns.Add(dcDropCol);
DataRow dr = dtMain.NewRow();
dr["DropDown Col"] = 100;
dtMain.Rows.Add(dr);
var uniqueDropdownValues = lstDrp.GroupBy(s => s.DropdownValue).Select(s => s.First());
GridViewComboBoxColumn drpCol = new GridViewComboBoxColumn();
radGridView1.Columns.Add(drpCol); //first add the column
//drpCol.DataType = typeof(int); //then change its data type to change the filtering type from string to int
drpCol.Name = "DropDown Col";
drpCol.HeaderText = "Dropdown Col";
drpCol.FieldName = "Dropdown Col";
drpCol.DataSource = uniqueDropdownValues;
drpCol.ValueMember = "DropdownValue";
drpCol.DisplayMember = "DropdownValue";
drpCol.Width = 200;
drpCol.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
drpCol.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
drpCol.AllowFiltering = true;
radGridView1.EnableFiltering = true;
radGridView1.ShowHeaderCellButtons = true;
radGridView1.DataSource = dtMain;
radGridView1.AllowAddNewRow = true;
To reproduce:
- Enable the search row in the 50000 rows example.
- Set the 5 last rows RowIndex value to null.
- Set the filter of the RowIndex column to "Is null" and then to "Is not null"
- Type 499 in the search row.
- Set the filter of the RowIndex column to "Is null" and then to "Is not null" again.
Workaround:
public class MyGridViewSearchRowInfo : GridViewSearchRowInfo
{
public MyGridViewSearchRowInfo(GridViewInfo viewInfo) : base(viewInfo)
{
}
protected override int GetCurrentCellTraverserColumnIndex()
{
if (this.ViewTemplate.MasterTemplate.Owner.CurrentRow == null)
{
return -1;
}
return base.GetCurrentCellTraverserColumnIndex();
}
}
//change the row like this:
void radGridViewDemo_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e)
{
if (e.RowInfo is GridViewSearchRowInfo)
{
e.RowInfo = new MyGridViewSearchRowInfo(e.ViewInfo);
}
}
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.
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();
}
}
To reproduce, use the following code and afterwards check the CurrentRow.Index property:
this.grid.BeginUpdate();
GridViewDataRowInfo newRow = new GridViewDataRowInfo(grid.MasterView);
this.grid.Rows.Add(newRow);
this.grid.EndUpdate();
Workaround:
radGridView1.Rows.IndexOf(radGridView1.CurrentRow);
To reproduce:
public Form1()
{
InitializeComponent();
GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn("DecimalColumn");
decimalColumn.FormatString = "{0:N0}";
decimalColumn.FieldName = "Price";
radGridView1.MasterTemplate.Columns.Add(decimalColumn);
GridViewCommandColumn commandColumn = new GridViewCommandColumn("CommandColumn");
commandColumn.FormatString = "{0:N0}";
commandColumn.FieldName = "Price";
radGridView1.MasterTemplate.Columns.Add(commandColumn);
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.SaveLayout(@"..\..\..\layout.xml");
this.radGridView1.LoadLayout(@"..\..\..\layout.xml");
FillData();
}
private void FillData()
{
List<Item> items = new List<Item>();
for (int i = 0; i < 5; i++)
{
items.Add(new Item(i * 2.35m));
}
radGridView1.DataSource = items;
}
public class Item
{
public decimal Price { get; set; }
public Item(decimal price)
{
this.Price = price;
}
}
Workaround: use the CellFormatting event and format the GridCommandCellElement.CommandButton.Text property:
private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.Column is GridViewCommandColumn && e.CellElement.Value != null)
{
GridCommandCellElement commandCell = e.CellElement as GridCommandCellElement;
commandCell.CommandButton.Text = string.Format("{0:N0}", e.CellElement.Value);
}
}
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;
}
}
To reproduce:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CustomersTableAdapter.Fill(Me.NwindDataSet.Customers)
Me.RadGridView1.BestFitColumns(Telerik.WinControls.UI.BestFitColumnMode.AllCells)
Me.RadGridView1.Columns(2).IsPinned = True
Me.RadGridView1.Columns(2).PinPosition = Telerik.WinControls.UI.PinnedColumnPosition.Left
Me.RadGridView1.Columns(5).IsPinned = True
Me.RadGridView1.Columns(5).PinPosition = Telerik.WinControls.UI.PinnedColumnPosition.Left
Dim summaryItem As New GridViewSummaryItem()
summaryItem.Name = "ContactTitle"
summaryItem.Aggregate = GridAggregateFunction.Count
Dim summaryRowItem As New GridViewSummaryRowItem()
summaryRowItem.Add(summaryItem)
Me.RadGridView1.SummaryRowsBottom.Add(summaryRowItem)
Me.RadGridView1.MasterTemplate.ShowTotals = True
Me.RadGridView1.EnableKineticScrolling = True
Me.RadGridView1.MasterView.SummaryRows(0).PinPosition = PinnedRowPosition.Bottom
End Sub
Please refer to the attached gif file.
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 form with a button on it where on its Click event you show another form with the following code snippet:
public class Dummy
{
public int ID { get; set; }
public string Description { get; set; }
}
public Form1()
{
InitializeComponent();
this.radGridView1.FilterChanged += radGridView1_FilterChanged;
if (File.Exists(@"..\..\..\layout.xml"))
{
this.radGridView1.LoadLayout(@"..\..\..\layout.xml");
}
else
{
radGridView1.Columns.Add(new GridViewTextBoxColumn { HeaderText = "Id ", FieldName = "ID" });
radGridView1.Columns.Add(new GridViewTextBoxColumn { HeaderText = "Description", FieldName = "DESCRIPTION" });
}
radGridView1.EnableFiltering = true;
radGridView1.MasterTemplate.ShowHeaderCellButtons = true;
radGridView1.MasterTemplate.ShowFilteringRow = true;
var items = new List<Dummy>();
for (int i = 0; i < 20; i++)
{
var dummy = new Dummy
{
ID = i,
Description = string.Format("Description_{0}", i)
};
items.Add(dummy);
}
radGridView1.AutoGenerateColumns = false;
radGridView1.DataSource = items;
}
private void radGridView1_FilterChanged(object sender, GridViewCollectionChangedEventArgs e)
{
this.radGridView1.SaveLayout(@"..\..\..\layout.xml");
}
Please refer to the attached gif file illustrating the steps.
To reproduce:
private void Form1_Load(object sender, EventArgs e)
{
GridSearchRowElement searchRow = null;
foreach (GridRowElement row in this.radGridView1.TableElement.VisualRows)
{
if (row is GridSearchRowElement)
{
searchRow = row as GridSearchRowElement;
break;
}
}
if (searchRow != null)
{
searchRow.SearchCellElement.SearchBoxWidth = 400;
}
}
Workaround:
radGridView1.TableElement.InvalidateMeasure(true);
radGridView1.TableElement.UpdateLayout();
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();
}
To reproduce:
public class ProgressBarCellElement : GridDataCellElement
{
public ProgressBarCellElement(GridViewColumn column, GridRowElement row) : base(column, row)
{
}
private RadProgressBarElement radProgressBarElement;
protected override void CreateChildElements()
{
base.CreateChildElements();
radProgressBarElement = new RadProgressBarElement();
this.Children.Add(radProgressBarElement);
}
protected override void SetContentCore(object value)
{
if (this.Value != null && this.Value != DBNull.Value)
{
this.radProgressBarElement.Value1 = Convert.ToInt16(this.Value);
}
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(GridDataCellElement);
}
}
public override bool IsCompatible(GridViewColumn data, object context)
{
return data is ProgressBarColumn && context is GridDataRowElement;
}
}
public class ProgressBarColumn : GridViewDataColumn
{
public ProgressBarColumn() : base()
{
}
public ProgressBarColumn(string fieldName) : base(fieldName)
{
}
public override Type GetCellType(GridViewRowInfo row)
{
if (row is GridViewDataRowInfo)
{
return typeof(ProgressBarCellElement);
}
return base.GetCellType(row);
}
}
To reproduce: - Use RadDock with MDI mode. - Add a form that contains a grid. - Set the theme to Aqua. Workaround: grid.GridViewElement.ForeColor = Color.Black;