Hello
I have some problem with displaying RadGroupBox on HDPI that host in UserControl/System.Windows.Form and must be AutoSize = true.
In our scenario, the RadGroupBox contains RadLabel and must change size depending on the size of the text. So we set AutoSize = true. However such RadGroupBox have incorrect font scaling in the header, the font becomes at least 2 times larger than it should be, and if GB is in the scrolling container (like in the example below) even larger.
If groupbox is hosted in RadForm the bug is not reproducible.
I use Telerik 2018.3.1016.20 with .Net 3.5
I very much rely on your help and advice.
Here are examples of my code and screenshots from different DPI.
100% (Form) https://c2n.me/3Z4oYcS
100% (RadForm) https://c2n.me/3Z4p2L0
200% (Form) https://clip2net.com/s/3Z4pjSv
200% (RadForm) https://clip2net.com/s/3Z4pbV0
using
System.ComponentModel;
using
System.Drawing;
using
System.Drawing.Drawing2D;
using
System.Windows.Forms;
using
Telerik.WinControls;
using
Telerik.WinControls.Primitives;
using
Telerik.WinControls.UI;
namespace
PP.DesignExamples.BugsForTelerik
{
public
class
Form6 : Form
{
private
RadScrollablePanel actionsScroll;
private
RadGroupBox gbAutosizeTrue;
private
RadLabel lblAutosizeTrueContent;
private
RadGroupBox gbAutosizeFalse;
private
RadLabel lblAutosizeFalseContent;
public
Form6()
{
InitializeComponent();
}
private
void
InitializeComponent()
{
actionsScroll =
new
RadScrollablePanel();
gbAutosizeTrue =
new
RadGroupBox();
lblAutosizeTrueContent =
new
RadLabel();
gbAutosizeFalse =
new
RadGroupBox();
lblAutosizeFalseContent =
new
RadLabel();
((ISupportInitialize)(actionsScroll)).BeginInit();
actionsScroll.PanelContainer.SuspendLayout();
actionsScroll.SuspendLayout();
((ISupportInitialize)(gbAutosizeTrue)).BeginInit();
gbAutosizeTrue.SuspendLayout();
((ISupportInitialize)(lblAutosizeTrueContent)).BeginInit();
((ISupportInitialize)(gbAutosizeFalse)).BeginInit();
gbAutosizeFalse.SuspendLayout();
((ISupportInitialize)(lblAutosizeFalseContent)).BeginInit();
SuspendLayout();
//
// actionsScroll
//
actionsScroll.BackColor = Color.Transparent;
actionsScroll.Dock = DockStyle.Fill;
actionsScroll.ForeColor = Color.Transparent;
actionsScroll.Location =
new
Point(0, 0);
actionsScroll.Margin =
new
Padding(0);
actionsScroll.MaximumSize =
new
Size(205, 0);
actionsScroll.MinimumSize =
new
Size(205, 0);
actionsScroll.Name =
"actionsScroll"
;
actionsScroll.Padding =
new
Padding(0);
//
// actionsScroll.PanelContainer
//
actionsScroll.PanelContainer.BackColor = Color.Transparent;
actionsScroll.PanelContainer.Controls.Add(gbAutosizeTrue);
actionsScroll.PanelContainer.Controls.Add(gbAutosizeFalse);
actionsScroll.PanelContainer.Location =
new
Point(0, 0);
actionsScroll.PanelContainer.Margin =
new
Padding(0);
actionsScroll.PanelContainer.Size =
new
Size(205, 423);
//
//
//
actionsScroll.RootElement.MaxSize =
new
Size(205, 0);
actionsScroll.RootElement.MinSize =
new
Size(205, 0);
actionsScroll.Size =
new
Size(205, 423);
actionsScroll.TabIndex = 4;
((RadScrollablePanelElement)(actionsScroll.GetChildAt(0))).Padding =
new
Padding(0);
((FillPrimitive)(actionsScroll.GetChildAt(0).GetChildAt(0))).Visibility = ElementVisibility.Hidden;
((BorderPrimitive)(actionsScroll.GetChildAt(0).GetChildAt(1))).Width = 0F;
((BorderPrimitive)(actionsScroll.GetChildAt(0).GetChildAt(1))).LeftWidth = 0F;
((BorderPrimitive)(actionsScroll.GetChildAt(0).GetChildAt(1))).TopWidth = 0F;
((BorderPrimitive)(actionsScroll.GetChildAt(0).GetChildAt(1))).RightWidth = 0F;
((BorderPrimitive)(actionsScroll.GetChildAt(0).GetChildAt(1))).BottomWidth = 0F;
((BorderPrimitive)(actionsScroll.GetChildAt(0).GetChildAt(1))).Visibility = ElementVisibility.Hidden;
//
// gbAutosizeTrue
//
gbAutosizeTrue.AccessibleRole = AccessibleRole.Grouping;
gbAutosizeTrue.AutoSize =
true
;
gbAutosizeTrue.BackColor = Color.Transparent;
gbAutosizeTrue.Controls.Add(lblAutosizeTrueContent);
gbAutosizeTrue.Dock = DockStyle.Top;
gbAutosizeTrue.GroupBoxStyle = RadGroupBoxStyle.Office;
gbAutosizeTrue.HeaderText =
"AutoSize = true"
;
gbAutosizeTrue.Location =
new
Point(0, 100);
gbAutosizeTrue.MinimumSize =
new
Size(0, 100);
gbAutosizeTrue.Name =
"gbAutosizeTrue"
;
gbAutosizeTrue.Padding =
new
Padding(4, 28, 4, 0);
//
//
//
gbAutosizeTrue.RootElement.AutoSize =
false
;
gbAutosizeTrue.RootElement.MinSize =
new
Size(0, 100);
gbAutosizeTrue.Size =
new
Size(205, 100);
gbAutosizeTrue.TabIndex = 8;
gbAutosizeTrue.Text =
"AutoSize = true"
;
((RadGroupBoxElement)(gbAutosizeTrue.GetChildAt(0))).Padding =
new
Padding(4, 28, 4, 0);
((FillPrimitive)(gbAutosizeTrue.GetChildAt(0).GetChildAt(0).GetChildAt(0))).BackColor = Color.FromArgb(176, 223, 226);
((GroupBoxHeader)(gbAutosizeTrue.GetChildAt(0).GetChildAt(1))).GroupBoxStyle = RadGroupBoxStyle.Office;
((GroupBoxHeader)(gbAutosizeTrue.GetChildAt(0).GetChildAt(1))).ForeColor = Color.DodgerBlue;
((FillPrimitive)(gbAutosizeTrue.GetChildAt(0).GetChildAt(1).GetChildAt(0))).BackColor = Color.Transparent;
((FillPrimitive)(gbAutosizeTrue.GetChildAt(0).GetChildAt(1).GetChildAt(0))).SmoothingMode = SmoothingMode.None;
((FillPrimitive)(gbAutosizeTrue.GetChildAt(0).GetChildAt(1).GetChildAt(0))).AutoSize =
true
;
((FillPrimitive)(gbAutosizeTrue.GetChildAt(0).GetChildAt(1).GetChildAt(0))).Margin =
new
Padding(0);
((TextPrimitive)(gbAutosizeTrue.GetChildAt(0).GetChildAt(1).GetChildAt(2).GetChildAt(1))).Text =
"AutoSize = true"
;
((TextPrimitive)(gbAutosizeTrue.GetChildAt(0).GetChildAt(1).GetChildAt(2).GetChildAt(1))).LineLimit =
false
;
((TextPrimitive)(gbAutosizeTrue.GetChildAt(0).GetChildAt(1).GetChildAt(2).GetChildAt(1))).Font =
new
Font(
"Arial"
, 11.25F, FontStyle.Bold, GraphicsUnit.Point, 0);
((TextPrimitive)(gbAutosizeTrue.GetChildAt(0).GetChildAt(1).GetChildAt(2).GetChildAt(1))).Margin =
new
Padding(7, 0, 0, 0);
((TextPrimitive)(gbAutosizeTrue.GetChildAt(0).GetChildAt(1).GetChildAt(2).GetChildAt(1))).Alignment = ContentAlignment.MiddleLeft;
//
// lblAutosizeTrueContent
//
lblAutosizeTrueContent.Dock = DockStyle.Top;
lblAutosizeTrueContent.Location =
new
Point(4, 28);
lblAutosizeTrueContent.Margin =
new
Padding(16);
lblAutosizeTrueContent.Name =
"lblAutosizeTrueContent"
;
//
//
//
lblAutosizeTrueContent.RootElement.MaxSize =
new
Size(0, 0);
lblAutosizeTrueContent.Size =
new
Size(197, 18);
lblAutosizeTrueContent.TabIndex = 2;
lblAutosizeTrueContent.Text =
"description will be here"
;
((RadLabelElement)(lblAutosizeTrueContent.GetChildAt(0))).TextAlignment = ContentAlignment.MiddleLeft;
((RadLabelElement)(lblAutosizeTrueContent.GetChildAt(0))).Text =
"description will be here"
;
((FillPrimitive)(lblAutosizeTrueContent.GetChildAt(0).GetChildAt(0))).AutoSizeMode = RadAutoSizeMode.Auto;
((FillPrimitive)(lblAutosizeTrueContent.GetChildAt(0).GetChildAt(0))).StretchHorizontally =
false
;
//
// gbAutosizeFalse
//
gbAutosizeFalse.AccessibleRole = AccessibleRole.Grouping;
gbAutosizeFalse.BackColor = Color.Transparent;
gbAutosizeFalse.Controls.Add(lblAutosizeFalseContent);
gbAutosizeFalse.Dock = DockStyle.Top;
gbAutosizeFalse.GroupBoxStyle = RadGroupBoxStyle.Office;
gbAutosizeFalse.HeaderText =
"AutoSize = false"
;
gbAutosizeFalse.Location =
new
Point(0, 0);
gbAutosizeFalse.MinimumSize =
new
Size(0, 100);
gbAutosizeFalse.Name =
"gbAutosizeFalse"
;
gbAutosizeFalse.Padding =
new
Padding(4, 28, 4, 0);
//
//
//
gbAutosizeFalse.RootElement.AutoSize =
false
;
gbAutosizeFalse.RootElement.MinSize =
new
Size(0, 100);
gbAutosizeFalse.Size =
new
Size(205, 100);
gbAutosizeFalse.TabIndex = 8;
gbAutosizeFalse.Text =
"AutoSize = false"
;
((RadGroupBoxElement)(gbAutosizeFalse.GetChildAt(0))).Padding =
new
Padding(4, 28, 4, 0);
((FillPrimitive)(gbAutosizeFalse.GetChildAt(0).GetChildAt(0).GetChildAt(0))).BackColor = Color.FromArgb(176, 223, 226);
((GroupBoxHeader)(gbAutosizeFalse.GetChildAt(0).GetChildAt(1))).GroupBoxStyle = RadGroupBoxStyle.Office;
((GroupBoxHeader)(gbAutosizeFalse.GetChildAt(0).GetChildAt(1))).ForeColor = Color.DodgerBlue;
((FillPrimitive)(gbAutosizeFalse.GetChildAt(0).GetChildAt(1).GetChildAt(0))).BackColor = Color.Transparent;
((FillPrimitive)(gbAutosizeFalse.GetChildAt(0).GetChildAt(1).GetChildAt(0))).SmoothingMode = SmoothingMode.None;
((FillPrimitive)(gbAutosizeFalse.GetChildAt(0).GetChildAt(1).GetChildAt(0))).AutoSize =
true
;
((FillPrimitive)(gbAutosizeFalse.GetChildAt(0).GetChildAt(1).GetChildAt(0))).Margin =
new
Padding(0);
((TextPrimitive)(gbAutosizeFalse.GetChildAt(0).GetChildAt(1).GetChildAt(2).GetChildAt(1))).Text =
"AutoSize = false"
;
((TextPrimitive)(gbAutosizeFalse.GetChildAt(0).GetChildAt(1).GetChildAt(2).GetChildAt(1))).LineLimit =
false
;
((TextPrimitive)(gbAutosizeFalse.GetChildAt(0).GetChildAt(1).GetChildAt(2).GetChildAt(1))).Font =
new
Font(
"Arial"
, 11.25F, FontStyle.Bold, GraphicsUnit.Point, 0);
((TextPrimitive)(gbAutosizeFalse.GetChildAt(0).GetChildAt(1).GetChildAt(2).GetChildAt(1))).Margin =
new
Padding(7, 0, 0, 0);
((TextPrimitive)(gbAutosizeFalse.GetChildAt(0).GetChildAt(1).GetChildAt(2).GetChildAt(1))).Alignment = ContentAlignment.MiddleLeft;
//
// lblAutosizeFalseContent
//
lblAutosizeFalseContent.Dock = DockStyle.Top;
lblAutosizeFalseContent.Location =
new
Point(4, 28);
lblAutosizeFalseContent.Margin =
new
Padding(16);
lblAutosizeFalseContent.Name =
"lblAutosizeFalseContent"
;
//
//
//
lblAutosizeFalseContent.RootElement.MaxSize =
new
Size(0, 0);
lblAutosizeFalseContent.Size =
new
Size(197, 18);
lblAutosizeFalseContent.TabIndex = 2;
lblAutosizeFalseContent.Text =
"description will be here"
;
((RadLabelElement)(lblAutosizeFalseContent.GetChildAt(0))).TextAlignment = ContentAlignment.MiddleLeft;
((RadLabelElement)(lblAutosizeFalseContent.GetChildAt(0))).Text =
"description will be here"
;
((FillPrimitive)(lblAutosizeFalseContent.GetChildAt(0).GetChildAt(0))).AutoSizeMode = RadAutoSizeMode.Auto;
((FillPrimitive)(lblAutosizeFalseContent.GetChildAt(0).GetChildAt(0))).StretchHorizontally =
false
;
//
// Form6
//
AutoScaleDimensions =
new
SizeF(6F, 13F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize =
new
Size(311, 423);
Controls.Add(actionsScroll);
Name =
"Form6"
;
Text =
"Form6"
;
actionsScroll.PanelContainer.ResumeLayout(
false
);
actionsScroll.PanelContainer.PerformLayout();
((ISupportInitialize)(actionsScroll)).EndInit();
actionsScroll.ResumeLayout(
false
);
((ISupportInitialize)(gbAutosizeTrue)).EndInit();
gbAutosizeTrue.ResumeLayout(
false
);
gbAutosizeTrue.PerformLayout();
((ISupportInitialize)(lblAutosizeTrueContent)).EndInit();
((ISupportInitialize)(gbAutosizeFalse)).EndInit();
gbAutosizeFalse.ResumeLayout(
false
);
gbAutosizeFalse.PerformLayout();
((ISupportInitialize)(lblAutosizeFalseContent)).EndInit();
ResumeLayout(
false
);
}
}
}
In native WinForm forms, a property called AutoValidate can be changed to EnableAllowFocusChange to allow users to continue to other controls if validation fails for an errorProvider.
I am trying to mimic this behavior with radGridView. Currently, users are unable to move onto other cells or rows, or other controls outside of the gridView until they input correct data into the cell.
I want to be able to allow the user to work on other things, add rows, edit cells on a new row or an existing row, etc without forcing them to input something just to get rid of the validation. Only at the end of the process would I loop through all controls and cells to see if an error exists, and remind the user before they can continue on.
This is so that the user doesn't put in erroneous data into the cell just so they can move on. For example, if they do not know what the account code is for an item, they would have to ask someone else and this may take some time. They should be able to work on other things on the form in the mean time.
I've tried cancelling the editor and calling EndEdit on the current active editor, but this isn't working. Users are still locked in on a cell if validation failed. How do I allow the user to get out of the cell even if an error exists?
See below on what I have tried:
if (e.Row is GridViewDataRowInfo)
{
if (detailValidation.IsEmptyInput(((string)e.Value), out errorMsg) || (!detailValidation.IsValidDecimalFormat(((string)e.Value), out errorMsg)))
{
e.ActiveEditor.EndEdit();
e.Cancel = true;
var test = e.ActiveEditor as RadTextBoxEditor;
currentCell.BackColor = Color.FromArgb(255, 221, 221);
((GridViewDataRowInfo)e.Row).ErrorText = errorMsg;
}
else
{
((GridViewDataRowInfo)e.Row).ErrorText = string.Empty;
}
}
Hi,
I have this problem:
In a Form with a RadDock, in this RadDock two ToolWindows with one button each and two DocumentWindows. In a DocumentWindow, a RadGridView.
The RadGridView is with the event UserAddingRow:
private
void
RadGridView1_UserAddingRow(
object
sender, Telerik.WinControls.UI.GridViewRowCancelEventArgs e)
{
if
(e.Rows.Count() > 0 && e.Rows[0].Cells[
"Id"
].Value ==
null
)
{
e.Cancel =
true
;
this
.radGridView1.GridNavigator.Select(
this
.radGridView1.MasterView.TableAddNewRow,
this
.radGridView1.Columns[
"Id"
]);
this
.radGridView1.BeginEdit();
}
}
If you are editing a new row in the RadGridView with the value of "Id" null and you click on a button or in the tab of the other DocumentWindow, you don't stay in the new row. And the UserAddingRow event is fired many time.
Why? How to edit the column "Id" of the new row if you validate by clicking in other control?
Hello everyone,
When I run WinForm, the interface can perform related operations, but when I operate, the mouse will display refresh status;
how to change the mouse display mode to cursor display;
Hi ,
I used following link.
https://www.telerik.com/support/kb/winforms/gridview/details/creating-a-radradiobuttoncellelement
I want to do readonly for this column . I put readonly = true but still can click radiobutton. May I know how to do this column readonly true.
Thanks
Moe
hi
i have a problem i want save my data from gridview to dabase including update, deleting a row and adding a row
i populate radgridview from a datatable.
my delete button is click event on a image
and my addnew row is the button from da radgridview
the add new row works almost fine (the click event are not firing on the images.) but add the row to the database.
the delete "button" remove the row from datagrid but is not working removing from the database only radgrid,
is there way i can add delete and update radgridview and then i press a button and update the database?
Hello,
There are 3 hierarchical levels in my grid. I use "Load-on-Demand" method to load hierarchical data. Mastertemplate data is binding to a local collection.
My gridview is built basically like this :
Private Sub FrmMain_Load(sender As Object, e As EventArgs)
myGridView.MultiSelect = True
myGridView.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
myGridView.ReadOnly = True
myGridView.AllowRowResize = False
myGridView.MasterTemplate.SelectionMode = GridViewSelectionMode.FullRowSelect
myGridView.UseScrollbarsInHierarchy = True
myGridView.MasterTemplate.ShowChildViewCaptions = True
myGridView.MasterTemplate.ShowRowHeaderColumn = False
Call Load_Hierarchy()
AddHandler myGridView.RowSourceNeeded, AddressOf myGridView_RowSourceNeeded
myBase.Charge()
myGridView.DataSource =myBase
End Sub
Private Sub Load_Hierarchy()
Dim template_FirstLevel As New GridViewTemplate()
template_FirstLevel .Caption = "FirstLevel"
template_FirstLevel .AllowAddNewRow = False
template_FirstLevel .AllowDeleteRow = False
template_FirstLevel .AllowEditRow = False
template_FirstLevel .AllowRowResize = False
template_FirstLevel .AutoGenerateColumns = False
template_FirstLevel .AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
template_FirstLevel .ShowChildViewCaptions = True
template_FirstLevel .ShowRowHeaderColumn = False
Dim gCol_1 As GridViewTextBoxColumn = New GridViewTextBoxColumn("Col1")
Dim gCol_2 As GridViewTextBoxColumn = New GridViewTextBoxColumn("Col2")
template_FirstLevel.Columns.AddRange(New GridViewDataColumn() {gCol_1, gCol_2})
myGridView.MasterTemplate.Templates.Add(template_FirstLevel )
template_FirstLevel.HierarchyDataProvider = New GridViewEventDataProvider(template_FirstLevel)
'-------------------definition of Second Level template
Dim template_2ndLevel As New GridViewTemplate()
template_2ndLevel.Caption = "Second Level"
template_2ndLevel.AllowAddNewRow = False
template_2ndLevel.AllowDeleteRow = False
template_2ndLevel.AllowEditRow = False
template_2ndLevel.AutoGenerateColumns = False
template_2ndLevel.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
template_2ndLevel.ShowChildViewCaptions = True
template_2ndLevel.ShowRowHeaderColumn = False
Dim gCol_2nd1 As GridViewTextBoxColumn = New GridViewTextBoxColumn("Index")
Dim gCol_2nd2 As GridViewTextBoxColumn = New GridViewTextBoxColumn("Name")
template_2ndLevel.Columns.AddRange(New GridViewDataColumn() {gCol_2nd1 , gCol_2nd2})
template_FirstLevel.Templates.Add(template_2ndLevel)
template_2ndLevel.HierarchyDataProvider = New GridViewEventDataProvider(template_2ndLevel)
End Sub
Private Sub myGridView_RowSourceNeeded(sender As Object, e As GridViewRowSourceNeededEventArgs)
If e.ParentRow.HierarchyLevel = 0 Then '----First Level data load
Dim Masteritem As C_dbProduit = TryCast(e.ParentRow.DataBoundItem, C_Master)
------Do something to load data in FirstLevelItemsList by using Masteritem-------
For 1stItem fonction In FirstLevelItemsList
Dim row_1stL As GridViewRowInfo = e.Template.Rows.NewRow()
row_1stL.Cells("Col1").Value = 1stItem.data1
row_1stL.Cells("Col2").Value = 1stItem.data2
e.SourceCollection.Add(row_1stL)
Next
End If
If e.ParentRow.HierarchyLevel = 1 Then '----2nd Level data load
Dim 1stItem As C_1stItem = TryCast(e.ParentRow.DataBoundItem, C_1stItem)
Dim masterparentRow As GridViewRowInfo = TryCast(e.ParentRow.Parent, GridViewRowInfo)
Dim masteritem As C_Master = TryCast(parentRow.DataBoundItem, C_Master)
If 1stItem Is Nothing Then '-----------------e.ParentRow.DataBoundItem is always nothing
Exit Sub
End If
If masteritem Is Nothing Then'-----------------e.ParentRow.Parent.DataBoundItem is always Correct!
Exit Sub
End If
'------------Do something to load data in the collection of 2ndItem by using 1stItem-------
End If
End Sub
It works perfect to show mastertemplate and 1st hierarchical level. But when I expand 2nd level, its ParentRow.DataBoundItem (it should be selected 1st level data) is always nothing. But I can get DataBoundItem of e.ParentRow.Parent correctly.
In order to avoid memory overloading, I prefer load-on-demand method in hierarchy grid.
Please help me.
Thank you