Hi,
I am facing a strange problem. Can you please help about it?
Scenario
Actually, On my RadForm, I am opening another RAdForm. This second form has a RAdGridView. Whenever user closes this second form, it is programmmatically hided but not closed. The grid on the second form has just one row in which user can enter values.
Problem:
User opens the second form and enter some values in the grid and then closes the form(Acually hiding). Then user again open that second form, the value that user eneterd are still there. That is correct. I want so. But the problem is user can not now change the values in the grid. Somehow CellValueChanged event is not calling. And if it calls once then second time it is not calling. Why is it so?
Sorry for my bad english. Any help would be appreciated.
Thanks
5 Answers, 1 is accepted
I have tried this and I haven't been able to replicate your issue.
I've prepared a small exmaple for you.
Form1 Designer
namespace
RadControlsWinFormsApp1
{
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()
{
this
.radButton1 =
new
Telerik.WinControls.UI.RadButton();
((System.ComponentModel.ISupportInitialize)(
this
.radButton1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
)).BeginInit();
this
.SuspendLayout();
//
// radButton1
//
this
.radButton1.Location =
new
System.Drawing.Point(89, 107);
this
.radButton1.Name =
"radButton1"
;
this
.radButton1.Size =
new
System.Drawing.Size(130, 24);
this
.radButton1.TabIndex = 0;
this
.radButton1.Text =
"radButton1"
;
this
.radButton1.Click +=
new
System.EventHandler(
this
.radButton1_Click);
//
// Form1
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.ClientSize =
new
System.Drawing.Size(298, 279);
this
.Controls.Add(
this
.radButton1);
this
.Name =
"Form1"
;
//
//
//
this
.RootElement.ApplyShapeToControl =
true
;
this
.Text =
"Form1"
;
this
.ThemeName =
"ControlDefault"
;
((System.ComponentModel.ISupportInitialize)(
this
.radButton1)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
)).EndInit();
this
.ResumeLayout(
false
);
}
#endregion
private
Telerik.WinControls.UI.RadButton radButton1;
}
}
Form1.cs
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
Telerik.WinControls;
namespace
RadControlsWinFormsApp1
{
public
partial
class
Form1 : Telerik.WinControls.UI.RadForm
{
private
Form2 form2;
public
Form1()
{
InitializeComponent();
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
if
(form2 ==
null
)
{
form2 =
new
Form2();
form2.Show();
}
else
{
form2.Show();
}
}
}
}
Form2 Designer
namespace
RadControlsWinFormsApp1
{
partial
class
Form2
{
/// <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()
{
this
.radGridView1 =
new
Telerik.WinControls.UI.RadGridView();
this
.radButton1 =
new
Telerik.WinControls.UI.RadButton();
this
.radButton2 =
new
Telerik.WinControls.UI.RadButton();
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
.radButton1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
.radButton2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
)).BeginInit();
this
.SuspendLayout();
//
// radGridView1
//
this
.radGridView1.Location =
new
System.Drawing.Point(2, 1);
this
.radGridView1.Name =
"radGridView1"
;
this
.radGridView1.Size =
new
System.Drawing.Size(295, 218);
this
.radGridView1.TabIndex = 0;
this
.radGridView1.Text =
"radGridView1"
;
this
.radGridView1.CellValueChanged +=
new
Telerik.WinControls.UI.GridViewCellEventHandler(
this
.radGridView1_CellValueChanged);
//
// radButton1
//
this
.radButton1.Location =
new
System.Drawing.Point(156, 234);
this
.radButton1.Name =
"radButton1"
;
this
.radButton1.Size =
new
System.Drawing.Size(130, 24);
this
.radButton1.TabIndex = 1;
this
.radButton1.Text =
"Edit Record"
;
this
.radButton1.Click +=
new
System.EventHandler(
this
.radButton1_Click);
//
// radButton2
//
this
.radButton2.Location =
new
System.Drawing.Point(2, 234);
this
.radButton2.Name =
"radButton2"
;
this
.radButton2.Size =
new
System.Drawing.Size(130, 24);
this
.radButton2.TabIndex = 2;
this
.radButton2.Text =
"Hide Form"
;
this
.radButton2.Click +=
new
System.EventHandler(
this
.radButton2_Click);
//
// Form2
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.ClientSize =
new
System.Drawing.Size(298, 279);
this
.Controls.Add(
this
.radButton2);
this
.Controls.Add(
this
.radButton1);
this
.Controls.Add(
this
.radGridView1);
this
.Name =
"Form2"
;
//
//
//
this
.RootElement.ApplyShapeToControl =
true
;
this
.Text =
"Form2"
;
this
.ThemeName =
"ControlDefault"
;
this
.Load +=
new
System.EventHandler(
this
.Form2_Load);
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
.radButton1)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
.radButton2)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
)).EndInit();
this
.ResumeLayout(
false
);
}
#endregion
private
Telerik.WinControls.UI.RadGridView radGridView1;
private
Telerik.WinControls.UI.RadButton radButton1;
private
Telerik.WinControls.UI.RadButton radButton2;
}
}
Form2.cs
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
Telerik.WinControls.UI;
namespace
RadControlsWinFormsApp1
{
public
partial
class
Form2 : Telerik.WinControls.UI.RadForm
{
public
Form2()
{
InitializeComponent();
this
.radGridView1.Columns.Add(
new
GridViewTextBoxColumn(
"A"
));
this
.radGridView1.Columns.Add(
new
GridViewDecimalColumn(
"B"
));
this
.radGridView1.Rows.Add(
"A1"
, 1);
}
private
void
Form2_Load(
object
sender, EventArgs e)
{
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
this
.radGridView1.Rows[0].Cells[
"B"
].Value = Convert.ToInt32(
this
.radGridView1.Rows[0].Cells[
"B"
].Value) + 1;
}
private
void
radButton2_Click(
object
sender, EventArgs e)
{
this
.Hide();
}
private
void
radGridView1_CellValueChanged(
object
sender, GridViewCellEventArgs e)
{
MessageBox.Show(
"Cell Value Changed"
);
}
}
}
Hope that helps, but let me know if yuo have any questions
Richard
Did this help? If so, please remember to mark as answer. If you need further help, please let me know
Thanks
Richard
Thanks for your example. Actually instead of your this line of code, value is entered from user interface.
this
.radGridView1.Rows[0].Cells[
"B"
].Value = Convert.ToInt32(
this
.radGridView1.Rows[0].Cells[
"B"
].Value) + 1;
So I still has the problem. here is very short example.
RadForm1 Designer
namespace
TestRadGrid
{
partial
class
RadForm1
{
/// <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()
{
this
.radButton1 =
new
Telerik.WinControls.UI.RadButton();
((System.ComponentModel.ISupportInitialize)(
this
.radButton1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
)).BeginInit();
this
.SuspendLayout();
//
// radButton1
//
this
.radButton1.Location =
new
System.Drawing.Point(84, 127);
this
.radButton1.Name =
"radButton1"
;
this
.radButton1.Size =
new
System.Drawing.Size(130, 24);
this
.radButton1.TabIndex = 1;
this
.radButton1.Text =
"radButton1"
;
this
.radButton1.Click +=
new
System.EventHandler(
this
.radButton1_Click);
//
// RadForm1
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.ClientSize =
new
System.Drawing.Size(298, 279);
this
.Controls.Add(
this
.radButton1);
this
.Name =
"RadForm1"
;
//
//
//
this
.RootElement.ApplyShapeToControl =
true
;
this
.Text =
"RadForm1"
;
this
.ThemeName =
"ControlDefault"
;
((System.ComponentModel.ISupportInitialize)(
this
.radButton1)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
)).EndInit();
this
.ResumeLayout(
false
);
}
#endregion
private
Telerik.WinControls.UI.RadButton radButton1;
}
}
RadForm1 Class
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
Telerik.WinControls;
namespace
TestRadGrid
{
public
partial
class
RadForm1 : Telerik.WinControls.UI.RadForm
{
private
RadForm2 form2;
public
RadForm1()
{
InitializeComponent();
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
if
(form2 ==
null
)
{
form2 =
new
RadForm2();
}
form2.ShowDialog(
this
);
}
}
}
RadForm2 Designer
namespace
TestRadGrid
{
partial
class
RadForm2
{
/// <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.GridViewDecimalColumn gridViewDecimalColumn5 =
new
Telerik.WinControls.UI.GridViewDecimalColumn();
Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn6 =
new
Telerik.WinControls.UI.GridViewDecimalColumn();
this
.radGridView1 =
new
Telerik.WinControls.UI.RadGridView();
this
.radButton1 =
new
Telerik.WinControls.UI.RadButton();
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1.MasterTemplate)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
.radButton1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(
this
)).BeginInit();
this
.SuspendLayout();
//
// radGridView1
//
this
.radGridView1.BackColor = System.Drawing.Color.FromArgb(((
int
)(((
byte
)(191)))), ((
int
)(((
byte
)(219)))), ((
int
)(((
byte
)(255)))));
this
.radGridView1.Cursor = System.Windows.Forms.Cursors.Default;
this
.radGridView1.Font =
new
System.Drawing.Font(
"Segoe UI"
, 8.25F);
this
.radGridView1.ForeColor = System.Drawing.Color.Black;
this
.radGridView1.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this
.radGridView1.Location =
new
System.Drawing.Point(17, 41);
//
// radGridView1
//
this
.radGridView1.MasterTemplate.AllowAddNewRow =
false
;
this
.radGridView1.MasterTemplate.AllowDeleteRow =
false
;
gridViewDecimalColumn5.FormatString =
""
;
gridViewDecimalColumn5.HeaderText =
"column1"
;
gridViewDecimalColumn5.Name =
"column1"
;
gridViewDecimalColumn5.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
gridViewDecimalColumn5.Width = 101;
gridViewDecimalColumn6.FormatString =
""
;
gridViewDecimalColumn6.HeaderText =
"column2"
;
gridViewDecimalColumn6.Name =
"column2"
;
gridViewDecimalColumn6.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
gridViewDecimalColumn6.Width = 139;
this
.radGridView1.MasterTemplate.Columns.AddRange(
new
Telerik.WinControls.UI.GridViewDataColumn[] {
gridViewDecimalColumn5,
gridViewDecimalColumn6});
this
.radGridView1.Name =
"radGridView1"
;
this
.radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.No;
//
//
//
this
.radGridView1.RootElement.ForeColor = System.Drawing.Color.Black;
this
.radGridView1.ShowGroupPanel =
false
;
this
.radGridView1.Size =
new
System.Drawing.Size(269, 150);
this
.radGridView1.TabIndex = 0;
this
.radGridView1.Text =
"radGridView1"
;
//
// radButton1
//
this
.radButton1.Location =
new
System.Drawing.Point(86, 218);
this
.radButton1.Name =
"radButton1"
;
this
.radButton1.Size =
new
System.Drawing.Size(130, 24);
this
.radButton1.TabIndex = 2;
this
.radButton1.Text =
"radButton1"
;
this
.radButton1.Click +=
new
System.EventHandler(
this
.radButton1_Click);
//
// RadForm2
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.ClientSize =
new
System.Drawing.Size(298, 279);
this
.Controls.Add(
this
.radButton1);
this
.Controls.Add(
this
.radGridView1);
this
.Name =
"RadForm2"
;
//
//
//
this
.RootElement.ApplyShapeToControl =
true
;
this
.Text =
"RadForm2"
;
this
.ThemeName =
"ControlDefault"
;
this
.Load +=
new
System.EventHandler(
this
.RadForm2_Load);
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1.MasterTemplate)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
.radButton1)).EndInit();
((System.ComponentModel.ISupportInitialize)(
this
)).EndInit();
this
.ResumeLayout(
false
);
}
#endregion
private
Telerik.WinControls.UI.RadGridView radGridView1;
private
Telerik.WinControls.UI.RadButton radButton1;
}
}
RadForm2 Class
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
Telerik.WinControls;
namespace
TestRadGrid
{
public
partial
class
RadForm2 : Telerik.WinControls.UI.RadForm
{
public
RadForm2()
{
InitializeComponent();
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
Hide();
}
private
void
RadForm2_Load(
object
sender, EventArgs e)
{
if
(radGridView1.RowCount < 1)
radGridView1.Rows.AddNew();
//radGridView1.Rows.Add(1000,1000); //just chaning value first time
}
}
}
Regards!
I can replicate your issue, which as far as I can see will need to be fixed by Telerik in an upcoming release. I will look for a workaround for you. In the meantime, I'd suggest opening a support ticket, and send them the example that you have given, also quuoting this forum thread
I'll let you know if/when I can find a workaround for you.
Richard
Thank you for writing and for the provided details for reproducing this issue.
I have tested the described scenario and indeed it seems that there is an issue. We will investigate this case and we will address it in a future release. Meanwhile, I have noticed that calling the Show method instead of the ShowDialog avoids this issue and everything works as expected.
I have added this issue into our PITS. Your Telerik points have been updated for this report.
Best wishes,
Stefan
the Telerik team