Hello everybody.
-I'm new with telerik , I use Winforms q2 2014 sp1 , and I have a GridView ,that contains three column ,CheckBowColumn,DateTimeColumn and ComboBoxColumn , I want that when I Check a CheckBox the Columns Date and Combo be enabled , else the Text of Date and Combo cleared and disabled.
How can I make this please ?? and thank's for help :)
-I'm new with telerik , I use Winforms q2 2014 sp1 , and I have a GridView ,that contains three column ,CheckBowColumn,DateTimeColumn and ComboBoxColumn , I want that when I Check a CheckBox the Columns Date and Combo be enabled , else the Text of Date and Combo cleared and disabled.
How can I make this please ?? and thank's for help :)
4 Answers, 1 is accepted
0
Hello,
Thank you for contacting us.
The desired functionality can be achieved by using the the CellFormatting event:
More information about this event can be found here: Formatting Cells.
Please let me know if there is something else I can help you with.
Regards,
Dimitar
Telerik
Thank you for contacting us.
The desired functionality can be achieved by using the the CellFormatting event:
public
Form1()
{
InitializeComponent();
radGridView1.Columns.Add(
new
GridViewCheckBoxColumn(
"CheckBox"
) { EditMode = EditMode.OnValueChange });
radGridView1.DataSource = GetTable();
radGridView1.CellFormatting += radGridView1_CellFormatting;
}
void
radGridView1_CellFormatting(
object
sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if
(e.Column.Name !=
"CheckBox"
)
{
if
(e.Row.Cells[0].Value !=
null
&& (
bool
)e.Row.Cells[0].Value )
{
e.CellElement.Enabled =
true
;
}
else
{
e.CellElement.Enabled =
false
;
e.CellElement.Text =
""
;
}
}
}
More information about this event can be found here: Formatting Cells.
Please let me know if there is something else I can help you with.
Regards,
Dimitar
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Free
Top achievements
Rank 1
answered on 02 Dec 2014, 04:47 PM
Thank you for your reply , but I want that the seconde column that name's "post" be fixed and dont clear text ?
0
Accepted
Hi Free,
Thank you for writing back.
You can update the CellFormatting event and skip the text clearing for the second column:
Do not hesitate to contact us if you have other questions.
Regards,
Dimitar
Telerik
Thank you for writing back.
You can update the CellFormatting event and skip the text clearing for the second column:
void
radGridView1_CellFormatting(
object
sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
if
(e.Column.Name !=
"CheckBox"
)
{
if
(e.Row.Cells[0].Value !=
null
&& (
bool
)e.Row.Cells[0].Value )
{
e.CellElement.Enabled =
true
;
}
else
{
e.CellElement.Enabled =
false
;
if
(e.Column.Name !=
"SecondColumnName"
)
{
e.CellElement.Text =
""
;
}
}
}
}
Do not hesitate to contact us if you have other questions.
Dimitar
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Free
Top achievements
Rank 1
answered on 05 Dec 2014, 05:42 PM
Thank's Dimitar it was very helpful (y)