EMRE ANDIC
Top achievements
Rank 1
EMRE ANDIC
asked on 06 Apr 2010, 01:54 PM
Hi,
I need to know how can I enable or disable ReadOnly property of a RadGridView's row. I have CheckBox column, and I want to manage ReadOnly property of selected row with checkboxes.
I need to know how can I enable or disable ReadOnly property of a RadGridView's row. I have CheckBox column, and I want to manage ReadOnly property of selected row with checkboxes.
9 Answers, 1 is accepted
0
Hi EMRE ANDIC,
Thank you for the question.
One way to implement the described requirement is to cancel the CellBeginEdit event in order to mimic read only behavior depending on your check box column value. Please, consider the following code:
Let me know if you have any other questions.
Greetings,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thank you for the question.
One way to implement the described requirement is to cancel the CellBeginEdit event in order to mimic read only behavior depending on your check box column value. Please, consider the following code:
void
radGridView1_CellBeginEdit(
object
sender, GridViewCellCancelEventArgs e)
{
if
(e.ColumnIndex != 0 && !CheckValue(
this
.radGridView1.CurrentRow.Cells[0].Value))
{
e.Cancel =
true
;
}
}
private
bool
CheckValue(
object
value)
{
if
(value
is
DBNull || value ==
null
)
{
return
false
;
}
bool
pValue;
if
(Boolean.TryParse(value.ToString(),
out
pValue))
{
return
pValue;
}
return
false
;
}
Let me know if you have any other questions.
Greetings,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
EMRE ANDIC
Top achievements
Rank 1
answered on 12 Apr 2010, 07:45 AM
Hi Martin Vasilev,
I decided to abandon checkbox event.
Is there another way to disable or enable a row according to any of a mouse event, because when I write e.Cancel = true/false to CellBeginEdit event, it enables or disables all rows, but I just want to effect a row at a time.
I decided to abandon checkbox event.
Is there another way to disable or enable a row according to any of a mouse event, because when I write e.Cancel = true/false to CellBeginEdit event, it enables or disables all rows, but I just want to effect a row at a time.
0
Hi EMRE ANDIC,
RadGridView uses virtualization (it reuses its RowElements), so you have to use CellFormatting or CellBeginEdit to do the job. Either method needs a condition to determine if particular row should be read-only or not. That means, if you abandon the check-box column approach, you still need a flag to determine the row state. For example you can use row's Tag property for this or just add a hidden column and use its value.
Sincerely yours,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
RadGridView uses virtualization (it reuses its RowElements), so you have to use CellFormatting or CellBeginEdit to do the job. Either method needs a condition to determine if particular row should be read-only or not. That means, if you abandon the check-box column approach, you still need a flag to determine the row state. For example you can use row's Tag property for this or just add a hidden column and use its value.
Sincerely yours,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Srilakshmi
Top achievements
Rank 1
answered on 01 Nov 2010, 01:14 PM
Hi,
I am also facing the same problem.I have a radgridview with a checkbox column in it.I have 6 rad combobox in a form in which on last combobox selectedindexchange the gridview loads.
The issue is some rows of gridview should be completely readonly while loading the grid or after immediately the grid has loaded .Please throw some light to solve this issue.
Regards
Luckee.
I am also facing the same problem.I have a radgridview with a checkbox column in it.I have 6 rad combobox in a form in which on last combobox selectedindexchange the gridview loads.
The issue is some rows of gridview should be completely readonly while loading the grid or after immediately the grid has loaded .Please throw some light to solve this issue.
Regards
Luckee.
0
Hello Srilakshmi,
Thank you for contacting us.
As I have mentioned in my previous post, probably the most suitable way to implement the described scenario is by using RowFormatting or CellFormatting event. Just create a conditional statement there, which will determine which row should be read only and which should be not. Some examples of using Row/CellFormatting event you can find in our product documentation.
Let me know if you have any additional questions.
Regards,
Martin Vasilev
the Telerik team
Thank you for contacting us.
As I have mentioned in my previous post, probably the most suitable way to implement the described scenario is by using RowFormatting or CellFormatting event. Just create a conditional statement there, which will determine which row should be read only and which should be not. Some examples of using Row/CellFormatting event you can find in our product documentation.
Let me know if you have any additional questions.
Regards,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Srilakshmi
Top achievements
Rank 1
answered on 09 Nov 2010, 06:45 AM
Hi Martin,
Thanks a lot for your reply and its working.
I have same kind of another problem with grid view.
I am using a telerik grid view in which a column should be validated with numeric values only on key press event.
Please help me regarding this.
Regards
Luckee.
Thanks a lot for your reply and its working.
I have same kind of another problem with grid view.
I am using a telerik grid view in which a column should be validated with numeric values only on key press event.
Please help me regarding this.
Regards
Luckee.
0
Emanuel Varga
Top achievements
Rank 1
answered on 09 Nov 2010, 09:31 AM
Hello Srilakshmi
,
Please take a look at the following example:
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Please take a look at the following example:
using
System;
using
System.ComponentModel;
using
System.Windows.Forms;
using
Telerik.WinControls.UI;
public
partial
class
Form1 : Form
{
private
RadGridView radGridView1;
public
Form1()
{
InitializeComponent();
this
.Controls.Add(radGridView1 =
new
RadGridView());
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGridView1.Dock = DockStyle.Fill;
radGridView1.CellBeginEdit +=
new
GridViewCellCancelEventHandler(radGridView1_CellBeginEdit);
}
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
radGridView1.DataSource =
new
TestsCollection(10);
}
void
radGridView1_CellBeginEdit(
object
sender, GridViewCellCancelEventArgs e)
{
if
(radGridView1.Columns[e.ColumnIndex].Name ==
"Digits"
)
{
var editManager = sender
as
GridViewEditManager;
var textBoxEditor = editManager.ActiveEditor
as
RadTextBoxEditor;
if
(textBoxEditor !=
null
)
{
var textBoxElement = textBoxEditor.EditorElement
as
RadTextBoxEditorElement;
textBoxElement.KeyPress +=
new
KeyPressEventHandler(textBoxElement_KeyPress);
}
}
}
void
textBoxElement_KeyPress(
object
sender, KeyPressEventArgs e)
{
e.Handled = !
char
.IsDigit(e.KeyChar);
}
}
public
class
Test
{
public
string
Text
{
get
;
set
;
}
public
string
Digits
{
get
;
set
;
}
}
public
class
TestsCollection : BindingList<Test>
{
public
TestsCollection(
int
noItems)
{
for
(
int
i = 0; i < noItems; i++)
{
this
.Add(
new
Test
{
Text =
"Text "
+ i.ToString(),
Digits = i.ToString()
});
}
}
}
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0
Avinash
Top achievements
Rank 1
answered on 17 Sep 2012, 07:41 AM
Hi,
I am also facing the same problem similar to that.
In my application I am using a rad grid view and in that I am having check box column. I have added one context menu because on the right click event of the rad grid i should enable all my check boxes. And after all my check boxes are enabled, I shoud close my rows in which the check boxes are enabled by using the buuton click event. So please provide me some help in solving the issue.
Regards,
Avinash
I am also facing the same problem similar to that.
In my application I am using a rad grid view and in that I am having check box column. I have added one context menu because on the right click event of the rad grid i should enable all my check boxes. And after all my check boxes are enabled, I shoud close my rows in which the check boxes are enabled by using the buuton click event. So please provide me some help in solving the issue.
Regards,
Avinash
0
Hi Avinash,
Nikolay
the Telerik team
I am not sure that I understand your scenario and the issues that you have with it completely. Therefore, I would kindly ask you to open a new support ticket and send me a sample project which demonstrates your case. In addition, describe where exactly you are experiencing issues. Last, but not least, please share more details on the action 'close my rows' and the meaning that you put in it.
Thank you for your cooperation. I am looking forward to receiving the details.
Nikolay
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>