I have a column defined in my gridview. It's name is "Energy".
I use the following code to bind my object to it. The object is a generic List<> of other objects.
((
GridViewComboBoxColumn)m_grd.Columns["Energy"]).DataSource = m_snc.Configuration.CurrentRadiationDevice.Energies;
The binding seems to work fine as far as display is concerned. Each "Energy" object has a ToString() override which allows me to see what I want in cases where I bind it to drop down's (like in this case). The combo box is filled with the appropriate display values; however when I select an item from the combo box and check to see the value's type, it is always a System.String instead of the object type of the item that is selected. In this case the expected behavior of the following method would be my custom object's type instead of System.String.
row.Cells["Energy"].Value.GetType()
Hi,
The new BackStageView of PageView control is awesome. But the Office2007Black theme doesn't work on it !
My question is how can we reduce the width of the left pane (where the buttons for each page is listed) ?
Thanks
Dim summaryItem As New GridViewSummaryItem()
summaryItem.Name = "Quantity"
summaryItem.Aggregate = GridAggregateFunction.Sum
Dim summaryRowItem As New GridViewSummaryRowItem()
summaryRowItem.Add(summaryItem)
Me.RadGridView1.SummaryRowsTop.Add(summaryRowItem)
Me.RadGridView1.SummaryRowsBottom.Add(summaryRowItem)
using
System.Collections.Generic;
using
System.Windows.Forms;
namespace
Test
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
List<DataItem> list =
new
List<DataItem>();
list.Add(
new
DataItem() { Name =
"Item 1"
});
list.Add(
new
DataItem() { Name =
"Item 3"
});
list.Add(
new
DataItem() { Name =
"Item 2"
});
radGridView1.DataSource = list;
}
}
public
class
DataItem
{
public
string
Name {
get
;
set
; }
}
}
Form1.Designer.cs
namespace
Test
{
partial
class
Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private
System.ComponentModel.IContainer components =
null
;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected
override
void
Dispose(
bool
disposing)
{
if
(disposing && (components !=
null
))
{
components.Dispose();
}
base
.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private
void
InitializeComponent()
{
Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn1 =
new
Telerik.WinControls.UI.GridViewTextBoxColumn();
Telerik.WinControls.Data.SortDescriptor sortDescriptor1 =
new
Telerik.WinControls.Data.SortDescriptor();
this
.radGridView1 =
new
Telerik.WinControls.UI.RadGridView();
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1.MasterTemplate)).BeginInit();
this
.SuspendLayout();
//
// radGridView1
//
this
.radGridView1.BackColor = System.Drawing.SystemColors.Control;
this
.radGridView1.Cursor = System.Windows.Forms.Cursors.Default;
this
.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this
.radGridView1.EnableCustomSorting =
true
;
this
.radGridView1.Font =
new
System.Drawing.Font(
"Segoe UI"
, 8.25F);
this
.radGridView1.ForeColor = System.Drawing.SystemColors.ControlText;
this
.radGridView1.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this
.radGridView1.Location =
new
System.Drawing.Point(0, 0);
//
// radGridView1
//
gridViewTextBoxColumn1.FieldName =
"Name"
;
gridViewTextBoxColumn1.FormatString =
""
;
gridViewTextBoxColumn1.HeaderText =
"Name"
;
gridViewTextBoxColumn1.Name =
"Name"
;
this
.radGridView1.MasterTemplate.Columns.AddRange(
new
Telerik.WinControls.UI.GridViewDataColumn[] {
gridViewTextBoxColumn1});
sortDescriptor1.PropertyName =
"Name"
;
this
.radGridView1.MasterTemplate.SortDescriptors.AddRange(
new
Telerik.WinControls.Data.SortDescriptor[] {
sortDescriptor1});
this
.radGridView1.Name =
"radGridView1"
;
this
.radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this
.radGridView1.Size =
new
System.Drawing.Size(284, 264);
this
.radGridView1.TabIndex = 0;
this
.radGridView1.Text =
"radGridView1"
;
//
// Form1
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.ClientSize =
new
System.Drawing.Size(284, 264);
this
.Controls.Add(
this
.radGridView1);
this
.Name =
"Form1"
;
this
.Text =
"Form1"
;
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1.MasterTemplate)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).EndInit();
this
.ResumeLayout(
false
);
}
#endregion
private
Telerik.WinControls.UI.RadGridView radGridView1;
}
}
The grid sorting is set in the Property Builder. But when line
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).EndInit();
is executed, the SortDescriptors collection is cleared and the grid becomes unsortable. This worked well in v.2010.3.10.1215.
Another problem concerns the custom sorting. I found that the CustomSorting handler is not called if the SortDescriptors collection is empty. I think this is not correct behavior, because the custom sorting logic is coded explitly and it should not depend on the grid sort descriptiors. If we note the first problem listed above, the CustomSorting handler is not called until the SortDescriptors collection is explicitly populated with the application code, or the column header is clicked by user.
Thank you.