Hello,
I'm trying to use RadGridView to export a datatable to Excel. I've created a method that takes a datatable as a parameter, creates a RadGridView, sets the dataSource to the datatable, and then exports. Problem is that the RadGridview doesn't seem to be getting populated with the contents of the dataTable. I feel like I'm missing something like 'gridView.DataBind();' but I can't find anything like that in the documentation. Code is below:
public static void ExportToExcel(DataTable myDT)
{ using (Telerik.WinControls.UI.RadGridView grid = new Telerik.WinControls.UI.RadGridView())
{
grid.AutoGenerateColumns = true;
grid.DataSource = myDT;
//grid.LoadElementTree();
//grid.Refresh();
GridViewSpreadExport spreadExporter = new GridViewSpreadExport(grid); SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
spreadExporter.RunExport("c:\\exportedFile.xlsx", exportRenderer);
}
}
Hello there,
I have some question about working with RadScrollablePanel.
Sometimes the RadScrollablePanel does not correctly display the scrollbars. For example, I use RadLabel bounded by width of RadScrollablePanel (using the dynamically changeable MaximumSize property).
I noticed that the vertical scrollbar does not always appear if the height of RadLabel and height of RadScrollablePanel.DisplayRectangle differ by about 10 pixels (at 96 DPI and Segoe UI 8.25pt font). This is clearly seen in example 1.
If we change width of RadScrollablePanel by a few pixels, we will see a different picture. A vertical scrollbar will be displayed on the screen and everything will look like it’s supposed to be. Keep in mind that the height of the elements remains unchanged. This is seen in example 2.
But that's not all. If we change the RadForm size a little more again, then we will see that the vertical scrollbar disappeared from the screen again; however, it's marked as Visible = True and if we take the focus on RadScrollablePanel, we can scroll the content using mouse wheel for example. This is seen in example 3.
Example 1: https://c2n.me/3ZabLEg
Example 2: https://c2n.me/3Zaclrf
Example 3: https://c2n.me/3ZacJol
At first sight, this may seem like a minor bug. However, considering that RadForms (or another container) with a fixed size can be used, and the text itself can change dynamically during operation, this bug causes problems with displaying information for users.
What guidelines can you give to work with RadScrollablePanel to prevent this bug?
Below I attach project with example. Please change extension from JPG to ZIP.
I use Telerik 2018.3.1016.20 with .Net 3.5 on Win7
Best regards.
HEllo
I would like to display a lower case greek delta in the header of a grid view
in the view formatting event I use the following
If e.CellElement.Text = "D" Then
e.CellElement.ColumnInfo.HeaderText = "d"
e.CellElement.Font = New Font("Symbol", MyPreference.Font.Size, FontStyle.Bold)
Else
e.CellElement.ResetValue(VisualElement.FontProperty, ValueResetFlags.Local)
End If
and it displays a latin lowercase "d"
However if I set a upper case latin D :
If e.CellElement.Text = "D" Then
e.CellElement.ColumnInfo.HeaderText = "D"
e.CellElement.Font = New Font("Symbol", MyPreference.Font.Size, FontStyle.Bold)
Else
e.CellElement.ResetValue(VisualElement.FontProperty, ValueResetFlags.Local)
End If
I do get a Greek uppercase Delta
Any clue why it does not work for the lowercase ?
Thanks a lot for any suggestion
Best regards
Pierre-Jean
Hello Telerik,
I'm looking to reproduce one of the gauge of Yahoo finance (see objectiv.jpg) but I'm stuck with my prototype (see actual.jpg) and the following questions !
- How to change the text of labels ?
- How to customize the rendering of the needleIndicator and its label ? (In my prototype I can't put the label above the NeedleIndicator with TextOffsetIndicator because it go outside the border of the control and is not drawn)
Thank you for your support
Marco Guignard
Hello, does anybody have experience with printing gridview where one of the columns contains strings formatted with barcode font?
I have three columns in the grid and my goal is to print gridview where one column is formatted with barcode font and the rest of columns are formatted with different font. I am able to set the barcode font to all datacells. It seems that GridPrintStyle does not support such granular columns formatting.
private
void
btnPrintDispatchedContainers_Click(
object
sender, EventArgs e)
{
GridPrintStyle style =
new
GridPrintStyle();
style.FitWidthMode = PrintFitWidthMode.NoFit;
style.PrintGrouping =
true
;
style.PrintHeaderOnEachPage =
true
;
style.PrintHiddenColumns =
false
;
Font barcodeFont =
new
Font(
"Code 128"
, 20f, FontStyle.Regular);
Font groupRowFont =
new
Font(
"Segoe UI"
, 12f, FontStyle.Bold);
style.CellFont = barcodeFont;
style.GroupRowFont = groupRowFont;
rgvDispatchedContainers.PrintStyle = style;
rgvDispatchedContainers.Print();
}
Any thoughts will be appreciated.
Hi,
When I query a RadGridView column's FilterDescriptor (.ToString()) I am getting basically an SQL representation of the applied filter, for example:
([coupon] >= 0.5) AND (([analytics_model_class] LIKE '%Other%' OR [analytics_model_class] NOT LIKE '%Card%'))
However, when I have to set the FilterDescriptor programmatically, I need to use the code as described here:
https://docs.telerik.com/devtools/winforms/controls/gridview/filtering/setting-filters-programmatically-(composite-descriptors)
This is pretty hard if I load a previously created SQL-like clause and now need to parse it in order to set the FilterDescriptors for all the columns.
Seems to me that there should be a utility available for this kind of purpose already, especially since Telerik already converts FilterDescriptors to SQL-like clauses.
Is there something that can help?
Thank you
Peter
Hello,
I am currently using a Scheduler control in weekview where the range of hours that's visible is about 6 hours.
The appointments are shown in this view but the text is always aligned at the top of the AppointmentElement.
When the top of the AppointmentElement is outside the view, you see only a colored rectangle and it's not clear what appointment is shown
Is there a way to
- align the text at the top of the AppointmentElement when the start-time is within the view.
- align the text at the top of the Schedulerview when the start-time is NOT within the view. (the text will be shown somewhere in the middle of the rectange)
I have added a picture to clarify my question.
Best regards
Patrick Vossen
I'm having an issue with updates not occurring in a while scrolling ListView with SimpleListViewVisualItem children down - scrolling up works fine. Figuring it has to do with virtualization/cell reuse and the VisualItemFormatting method is incomplete and needs to update the row.
Where am I going wrong?
Thanks,
_D
using
System;
using
System.ComponentModel;
using
System.Drawing;
using
System.Windows.Forms;
using
Telerik.WinControls.Layouts;
using
Telerik.WinControls.UI;
namespace
TelerikWinFormsApp4
{
public
partial
class
RadForm1 : Telerik.WinControls.UI.RadForm
{
public
RadForm1()
{
InitializeComponent();
this
.radListView1.VisualItemCreating +=
new
ListViewVisualItemCreatingEventHandler(
this
.radListView1_VisualItemCreating);
this
.radListView1.VisualItemFormatting +=
new
ListViewVisualItemEventHandler(radListView1_VisualItemFormatting);
// Populate BullJiveTestListItem with fluff
BindingList<BullJiveTestListItem> rows =
new
BindingList<BullJiveTestListItem>();
for
(
int
alpha = 65; alpha < 85; alpha++) rows.Add(
new
BullJiveTestListItem(Convert.ToChar(alpha).ToString()));
this
.Size =
new
Size(500, 300);
radListView1.DataSource = rows;
radListView1.ItemSize =
new
Size(0, 100);
radListView1.FullRowSelect =
true
;
}
private
void
radListView1_VisualItemCreating(
object
sender, ListViewVisualItemCreatingEventArgs e)
{
if
(radListView1.ViewType == ListViewType.ListView)
{
e.VisualItem =
new
RowVisualItem();
}
}
private
void
radListView1_VisualItemFormatting(
object
sender, ListViewVisualItemEventArgs e)
{
if
(radListView1.ViewType == ListViewType.ListView)
{
//BullJiveTestListItem v = (BullJiveTestListItem)e.VisualItem.Data.Value;
//????
}
}
}
public
class
RowVisualItem : SimpleListViewVisualItem
{
private
LightVisualElement hBox0, hBox1;
private
StackLayoutPanel horizontalLayout;
private
Point newSize =
new
Point(0, 100);
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
horizontalLayout =
new
StackLayoutPanel();
horizontalLayout.Orientation = Orientation.Horizontal;
hBox0 =
new
LightVisualElement();
hBox0.MinSize =
new
Size(newSize);
horizontalLayout.Children.Add(hBox0);
hBox1 =
new
LightVisualElement();
hBox1.MinSize =
new
Size(newSize);
horizontalLayout.Children.Add(hBox1);
Children.Add(horizontalLayout);
}
protected
override
void
SynchronizeProperties()
{
base
.SynchronizeProperties();
if
(
this
.FindAncestor<RadListViewElement>() ==
null
)
return
;
this
.Text =
"<html><span style=\"color:black;font-size:14.5pt;\">Text</span>"
;
hBox0.Size =
new
Size(newSize);
hBox0.Text =
"<html><span style=\"color:green;\">(hBox0)Value0: </span><span style=\"color:DarkMagenta;\">"
+
this
.Data[
"Value0"
] +
"</span>"
+
"<br><span style=\"color:red;\">(hBox0)Value1: </span><span style=\"color:blue;\">"
+
this
.Data[
"Value1"
] +
"</span>"
;
hBox1.Size =
new
Size(newSize);
hBox1.Text =
"<html><span style=\"color:darkblue;\">(hBox1)Value2: </span><span style=\"color:purple;\">"
+
this
.Data[
"Value2"
] +
"</span>"
+
"<br><span style=\"color:orange;\">(hBox1)Value3: </span><span style=\"color:gray;\">"
+
this
.Data[
"Value3"
] +
"</span>"
;
TextAlignment = ContentAlignment.TopLeft;
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(SimpleListViewVisualItem);
}
}
}
public
class
BullJiveTestListItem
{
public
BullJiveTestListItem(
string
s)
{
Value0 = s +
"0"
;
Value1 = s +
"1"
;
Value2 = s +
"2"
;
Value3 = s +
"3"
;
}
public
string
Value0 {
get
;
set
; }
public
string
Value1 {
get
;
set
; }
public
string
Value2 {
get
;
set
; }
public
string
Value3 {
get
;
set
; }
}
}