Dear Admins.
Using Telerik Winform UI R2 2019 SP1.
I'm trying to add Custom Cell in gridview column. (want to add 2 Buttons and a TextBox)
What i have did is
public
class
CustomCellElement : GridDataCellElement
{
private
RadButtonElement radButtonElement;
private
RadButtonElement radButtonElement1;
private
RadTextBoxElement radTextBoxElement;
public
CustomCellElement(GridViewColumn column, GridRowElement row) :
base
(column, row)
{
}
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
radButtonElement =
new
RadButtonElement
{
Text =
"-"
,
Margin =
new
Padding(1, 1, 2, 1)
};
radButtonElement.Click +=
new
EventHandler(radButtonElement_Click);
this
.Children.Add(radButtonElement);
this
.radTextBoxElement =
new
RadTextBoxElement
{
Margin =
new
Padding(1, 1, 1, 1),
TextAlign = HorizontalAlignment.Right
};
this
.Children.Add(radTextBoxElement);
radButtonElement1 =
new
RadButtonElement
{
Text =
"+"
,
Margin =
new
Padding(2, 1, 1, 1)
};
radButtonElement1.Click +=
new
EventHandler(radButtonElement1_Click);
this
.Children.Add(radButtonElement1);
}
private
void
radButtonElement_Click(
object
sender, EventArgs e)
{
int
value = Convert.ToInt32(radTextBoxElement.Text) - 1;
if
(value > 0)
radTextBoxElement.Text = Convert.ToString(value);
}
private
void
radButtonElement1_Click(
object
sender, EventArgs e)
{
int
value = Convert.ToInt32(radTextBoxElement.Text) + 1;
if
(value > 0)
radTextBoxElement.Text = Convert.ToString(value);
}
protected
override
void
DisposeManagedResources()
{
radButtonElement.Click -=
new
EventHandler(radButtonElement_Click);
radButtonElement1.Click -=
new
EventHandler(radButtonElement1_Click);
base
.DisposeManagedResources();
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(GridDataCellElement);
}
}
protected
override
SizeF ArrangeOverride(SizeF finalSize)
{
if
(
this
.Children.Count == 3)
{
float
textBoxWidth = finalSize.Width - radButtonElement.DesiredSize.Width - radButtonElement1.DesiredSize.Width;
RectangleF buttonRect =
new
RectangleF(0, 0, radButtonElement.DesiredSize.Width, finalSize.Height);
RectangleF textBoxRect =
new
RectangleF(radButtonElement.DesiredSize.Width - 1, 0, textBoxWidth - 1, finalSize.Height);
RectangleF button1Rect =
new
RectangleF(textBoxWidth + radButtonElement.DesiredSize.Width - 1, 0, radButtonElement1.DesiredSize.Width, finalSize.Height);
this
.Children[0].Arrange(buttonRect);
this
.Children[1].Arrange(textBoxRect);
this
.Children[2].Arrange(button1Rect);
}
return
finalSize;
}
}
public
class
CustomColumn : GridViewDataColumn
{
public
CustomColumn() :
base
()
{ }
public
CustomColumn(
string
fieldName) :
base
(fieldName)
{
}
public
CustomColumn(
string
uniqueName,
string
fieldName) :
base
(uniqueName, fieldName)
{
}
public
override
Type GetCellType(GridViewRowInfo row)
{
if
(row
is
GridViewDataRowInfo)
{
return
typeof
(CustomCellElement);
}
return
base
.GetCellType(row);
}
}
and How a Add it GridView
CustomColumn customColumn =
new
CustomColumn
{
Name =
"Qty"
,
FieldName =
"Qty"
,
HeaderText =
"Quantity"
,
Width = 150,
HeaderTextAlignment = ContentAlignment.MiddleRight,
TextAlignment = ContentAlignment.MiddleRight
};
radGridView1.MasterTemplate.Columns.Add(customColumn);
I'm Facing Display problem Please see Image.
Buttons are not displaying properly, cutting the sides. TextBox should be according to the height of GridView cell you can see empty area at the bottom.
How to get and set the value of text box. when row is adding directly to grid.
Please note that the Gridview AllowAddNewRow & AllowEditRow is set to False.(adding Row to GridView Programatically)
But I can Still change the value in the Textbox(Editing to textbox should be disabled.)
Apply the format like other column(please see image).
Thank you
Kashif
Hi,
How do I hide the 'x' (close) on the top/right side of a docked window tab?
(See screenshot)
Thanks,
-Lou
Hi,
I'm trying to update RadSheduler header text to show daily work hours. I'm implementing this from RadScheduler_ActiveViewChanged method, but the text is not changing unless I change active view. How can I resolve this issue?
Thanks for help
Karoon
private void radScheduler1_ActiveViewChanged(object sender,
SchedulerViewChangedEventArgs e)
{
toolWindow2.Text = e.NewView.ViewType.ToString();
if (e.NewView is SchedulerDayViewBase)
{
SchedulerDayViewBase dayViewBase = (SchedulerDayViewBase)e.NewView;
dayViewBase.Scheduler.HeaderFormat = "ddd MMM dd";
UpdateRadSchedulerHeader(dayViewBase);
}
}
I'm using the following line in UpdateRadSchedulerHeader method to update text:
((SchedulerHeaderCellElement)dayViewBase.Scheduler.ViewElement.Children[0].Children[j]).Text
+= "(Time
00:00:00)";
Dear Admins,
I want to Show the Desktop alert specific position on the screen
Like I have a Parent Form which covers the full screen. A Child form is Called from the Parent as ShowDialog.
The requirement is to Display the Alert on the Location of Child Form (Bellow the Tittle Bar of Child Form). the width of Alert will be Equal to the Width of Form.
How can i achieve this behavior.
Hello,
With the R3 2019 release of the UI for WPF suite, you have introduced a brand new VisualStudio2019 theme.
Is there a chance this theme will also soon be available for WinForms ?
Thanks,
Best regards
I'm using tags to selectively format cells and using automatic layout saving/loading. When a layout is loaded, cell tags are lost. Example code below. I feel like the cell tag should remain intact and this is a bug? I tried to include a project but only images are allowed on the forum.
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.IO;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
using
Telerik.WinControls;
using
Telerik.WinControls.UI;
namespace
TestGridViewTagsLayout
{
public
class
Form1 : Form
{
/// <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.TableViewDefinition tableViewDefinition3 =
new
Telerik.WinControls.UI.TableViewDefinition();
this
.radGridView1 =
new
Telerik.WinControls.UI.RadGridView();
this
.cmdLoadLayout =
new
System.Windows.Forms.Button();
this
.cmdSaveLayout =
new
System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1.MasterTemplate)).BeginInit();
this
.SuspendLayout();
//
// radGridView1
//
this
.radGridView1.Location =
new
System.Drawing.Point(12, 12);
//
//
//
this
.radGridView1.MasterTemplate.ViewDefinition = tableViewDefinition3;
this
.radGridView1.Name =
"radGridView1"
;
this
.radGridView1.Size =
new
System.Drawing.Size(776, 394);
this
.radGridView1.TabIndex = 0;
this
.radGridView1.CellFormatting +=
new
Telerik.WinControls.UI.CellFormattingEventHandler(
this
.RadGridView1_CellFormatting);
//
// cmdLoadLayout
//
this
.cmdLoadLayout.Location =
new
System.Drawing.Point(12, 415);
this
.cmdLoadLayout.Name =
"cmdLoadLayout"
;
this
.cmdLoadLayout.Size =
new
System.Drawing.Size(75, 23);
this
.cmdLoadLayout.TabIndex = 1;
this
.cmdLoadLayout.Text =
"Load Layout"
;
this
.cmdLoadLayout.UseVisualStyleBackColor =
true
;
this
.cmdLoadLayout.Click +=
new
System.EventHandler(
this
.CmdLoadLayout_Click);
//
// cmdSaveLayout
//
this
.cmdSaveLayout.Location =
new
System.Drawing.Point(93, 415);
this
.cmdSaveLayout.Name =
"cmdSaveLayout"
;
this
.cmdSaveLayout.Size =
new
System.Drawing.Size(75, 23);
this
.cmdSaveLayout.TabIndex = 1;
this
.cmdSaveLayout.Text =
"Save Layout"
;
this
.cmdSaveLayout.UseVisualStyleBackColor =
true
;
this
.cmdSaveLayout.Click +=
new
System.EventHandler(
this
.CmdSaveLayout_Click);
//
// Form1
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.ClientSize =
new
System.Drawing.Size(800, 450);
this
.Controls.Add(
this
.cmdSaveLayout);
this
.Controls.Add(
this
.cmdLoadLayout);
this
.Controls.Add(
this
.radGridView1);
this
.Name =
"Form1"
;
this
.Text =
"Form1"
;
this
.Load +=
new
System.EventHandler(
this
.Form1_Load);
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1.MasterTemplate)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).EndInit();
this
.ResumeLayout(
false
);
}
#endregion
private
Telerik.WinControls.UI.RadGridView radGridView1;
private
System.Windows.Forms.Button cmdLoadLayout;
private
System.Windows.Forms.Button cmdSaveLayout;
private
string
layoutXml =
null
;
public
Form1()
{
InitializeComponent();
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
List<TestEntity> list =
new
List<TestEntity>();
list.Add(
new
TestEntity() { a =
"1"
, b =
"1"
, c =
"1"
});
list.Add(
new
TestEntity() { a =
"1"
, b =
"2"
, c =
"2"
});
list.Add(
new
TestEntity() { a =
"3"
, b =
"1"
, c =
"1"
});
list.Add(
new
TestEntity() { a =
"1"
, b =
"1"
, c =
"1"
});
radGridView1.AutoGenerateColumns =
false
;
GridViewTextBoxColumn textBoxColumn =
new
GridViewTextBoxColumn();
textBoxColumn.Name =
"a"
;
textBoxColumn.HeaderText =
"A"
;
textBoxColumn.FieldName =
"a"
;
textBoxColumn.AutoSizeMode = BestFitColumnMode.AllCells;
radGridView1.MasterTemplate.Columns.Add(textBoxColumn);
textBoxColumn =
new
GridViewTextBoxColumn();
textBoxColumn.Name =
"b"
;
textBoxColumn.HeaderText =
"B"
;
textBoxColumn.FieldName =
"b"
;
textBoxColumn.AutoSizeMode = BestFitColumnMode.AllCells;
radGridView1.MasterTemplate.Columns.Add(textBoxColumn);
textBoxColumn =
new
GridViewTextBoxColumn();
textBoxColumn.Name =
"c"
;
textBoxColumn.HeaderText =
"C"
;
textBoxColumn.FieldName =
"c"
;
textBoxColumn.AutoSizeMode = BestFitColumnMode.AllCells;
radGridView1.MasterTemplate.Columns.Add(textBoxColumn);
radGridView1.DataSource = list;
HighlightFieldChanges();
radGridView1.TableElement.Update(GridUINotifyAction.Reset);
}
private
void
HighlightFieldChanges()
{
for
(
int
i = 1; i < radGridView1.RowCount; i++)
{
GridViewRowInfo prevRow = radGridView1.Rows[i - 1];
GridViewRowInfo curRow = radGridView1.Rows[i];
for
(
int
j = 0; j < prevRow.Cells.Count; j++)
{
if
(!(Convert.ToString(prevRow.Cells[j].Value).Equals(Convert.ToString(curRow.Cells[j].Value))))
{
prevRow.Cells[j].Tag =
true
;
}
}
}
}
private
void
RadGridView1_CellFormatting(
object
sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if
(((e.Row.Cells[e.ColumnIndex].Tag)
as
bool
?).GetValueOrDefault(
false
) ==
true
)
{
e.CellElement.DrawFill =
true
;
e.CellElement.BackColor = Color.LightYellow;
e.CellElement.NumberOfColors = 1;
}
else
{
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty, ValueResetFlags.Local);
}
}
private
void
CmdSaveLayout_Click(
object
sender, EventArgs e)
{
MemoryStream ms =
new
MemoryStream();
radGridView1.SaveLayout(ms);
ms.Flush();
ms.Position = 0;
StreamReader sr =
new
StreamReader(ms);
layoutXml = sr.ReadToEnd();
}
private
void
CmdLoadLayout_Click(
object
sender, EventArgs e)
{
MemoryStream ms =
new
MemoryStream();
StreamWriter sw =
new
StreamWriter(ms);
sw.Write(layoutXml);
sw.Flush();
ms.Position = 0;
radGridView1.LoadLayout(ms);
radGridView1.TableElement.Update(GridUINotifyAction.Reset);
}
}
public
class
TestEntity
{
public
string
a {
get
;
set
; }
public
string
b {
get
;
set
; }
public
string
c {
get
;
set
; }
}
}
My lineseries won't draw the line between points unless I use the category menu to change the palette at run time. I need to define my own palette.
What have I missed, or is this a bug?
Please see extracted solution that shows the problem. I've hand coded all the series etc as messing too much in the designer seems to corrupt the design file.
http://www.mediafire.com/file/0louxrb7fzx1ajt/testappchart.rar/file
'---------------------------------
Private Sub RadListview_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs) Handles RadListview.PreviewKeyDown
If Not (e.Modifiers = Keys.Shift) AndAlso e.KeyCode = Keys.Tab Then
My.Computer.Keyboard.SendKeys("{right}", True)
'SendKeys.Send("{right}")
ElseIf e.Modifiers = Keys.Shift AndAlso e.KeyCode = Keys.Tab Then
SendKeys.Send("{left}")
End If
End Sub