7 Answers, 1 is accepted
0
Accepted
Hi Uri,
Thank you for writing.
If I understand correctly, you want to insert a column before the expander element in RadGridView. If so, this would not be possible. However, if you can use the row header column cells for some kind of indication as you have demonstrates on the attached image. To do that you would have to use the ViewCellFormatting event of RadGridView:
More information about this event can be found here: http://www.telerik.com/help/winforms/gridview-cells-formatting-cells.html.
I hope that you find this information useful.
Regards,
Stefan
Telerik
Thank you for writing.
If I understand correctly, you want to insert a column before the expander element in RadGridView. If so, this would not be possible. However, if you can use the row header column cells for some kind of indication as you have demonstrates on the attached image. To do that you would have to use the ViewCellFormatting event of RadGridView:
void
radGridView1_ViewCellFormatting(
object
sender, CellFormattingEventArgs e)
{
GridRowHeaderCellElement rowHeaderCell = e.CellElement
as
GridRowHeaderCellElement;
if
(rowHeaderCell !=
null
)
{
rowHeaderCell.DrawFill =
true
;
rowHeaderCell.GradientStyle = GradientStyles.Solid;
if
(e.Row.Cells[
"ID"
].Value !=
null
&& (
int
)e.Row.Cells[
"ID"
].Value > 10)
{
rowHeaderCell.BackColor = Color.Red;
}
else
{
rowHeaderCell.BackColor = Color.Green;
}
}
}
More information about this event can be found here: http://www.telerik.com/help/winforms/gridview-cells-formatting-cells.html.
I hope that you find this information useful.
Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Alex
Top achievements
Rank 1
answered on 19 Jul 2013, 09:55 AM
Thank you Stefan,
Your tip was pretty helpful, i used this event to set my image on the row header column like this:
rowHeaderCell.BackgroundImage = img;
rowHeaderCell.BackgroundImageLayout = ImageLayout.Zoom;
but it would be much better if there was a way to set the width of the row header column. Is it possible?
Uri
Your tip was pretty helpful, i used this event to set my image on the row header column like this:
rowHeaderCell.BackgroundImage = img;
rowHeaderCell.BackgroundImageLayout = ImageLayout.Zoom;
but it would be much better if there was a way to set the width of the row header column. Is it possible?
Uri
0
Hello Uri,
You can change row header width. Please consider the following property:
I hope this helps.
Regards,
Stefan
Telerik
You can change row header width. Please consider the following property:
radGridView1.TableElement.RowHeaderColumnWidth = 100;
I hope this helps.
Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Alex
Top achievements
Rank 1
answered on 24 Jul 2013, 06:43 AM
Thanks Stefan,
It works and looks fine, but my customer keeps on insisting to insert a few columns before the expander element, so i'm looking for a workaround. I need to know what are my possibilities with the row header column:
1-Is it possible to hide the selection arrow on the row header?
2-Is it possible to insert a control into row header cells or to subclass it?
3-Is there any chance that Telerik will make it possible to insert columns before the expander in future versions?
Thanks ahead,
Uri
It works and looks fine, but my customer keeps on insisting to insert a few columns before the expander element, so i'm looking for a workaround. I need to know what are my possibilities with the row header column:
1-Is it possible to hide the selection arrow on the row header?
2-Is it possible to insert a control into row header cells or to subclass it?
3-Is there any chance that Telerik will make it possible to insert columns before the expander in future versions?
Thanks ahead,
Uri
0
Hi Uri,
Thank you for writing back.
Hope this helps, if you have any other questions or comments, please let me know.
Regards,
George
Telerik
Thank you for writing back.
- To hide the arrows on the header cells you can use ViewCellFormatting event and hide the arrow element:
void
radGridView1_ViewCellFormatting(
object
sender, CellFormattingEventArgs e)
{
GridHeaderCellElement headerCell = e.CellElement
as
GridHeaderCellElement;
if
(headerCell !=
null
)
{
headerCell.Arrow.Visibility = ElementVisibility.Collapsed;
}
}
- We have a great article in our help which should help you to create a custom header cell. You can read more about it here - http://www.telerik.com/help/winforms/gridview-cells-custom-cells.html
- We will consider adding such functionality in future if there is demand for it. We always try to adjust our planning with the needs of our customers.
Hope this helps, if you have any other questions or comments, please let me know.
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Alex
Top achievements
Rank 1
answered on 30 Jul 2013, 07:30 AM
Hi George,
Thank you for your reply.
1-I've tried the code in the ViewCellFormatting event but the error didn't disappear neither when i've set it to Collapsed nor Hidden.
2-The article explains how to create a custom cell which is great but i couldn't find a way to set it to the row header column. Also, the children of the cell must be subclasses of RadElement and not RadControl, so it would be helpful to sea an example of how to create a custom RadElement.
3-It would be great.
Uri
Thank you for your reply.
1-I've tried the code in the ViewCellFormatting event but the error didn't disappear neither when i've set it to Collapsed nor Hidden.
2-The article explains how to create a custom cell which is great but i couldn't find a way to set it to the row header column. Also, the children of the cell must be subclasses of RadElement and not RadControl, so it would be helpful to sea an example of how to create a custom RadElement.
3-It would be great.
Uri
0
Hi Uri,
Thank you for your reply.
Below is a simple example of custom header cell with one textbox and three buttons inside:
And a sample usage:
Would you please clarify for me which arrow are you referring to. Please see if it is the one shown on the attached picture (arrow.png).
I hope this information be of use, looking forward to your reply.
Regards,
George
Telerik
Thank you for your reply.
Below is a simple example of custom header cell with one textbox and three buttons inside:
public
class
MyHeaderCellElement : GridHeaderCellElement
{
private
RadButtonElement sumButton;
private
RadButtonElement divButton;
private
RadButtonElement modButton;
private
RadTextBoxElement textBox;
private
StackLayoutElement mathStack;
public
MyHeaderCellElement(GridViewColumn col, GridRowElement row)
:
base
(col, row)
{
this
.TextAlignment = ContentAlignment.TopCenter;
}
public
StackLayoutElement ElementsStack
{
get
{
return
this
.mathStack; }
}
public
RadTextBoxElement TextBox
{
get
{
return
this
.textBox; }
}
public
RadButtonElement SumButton
{
get
{
return
this
.sumButton; }
}
public
RadButtonElement DivButton
{
get
{
return
this
.divButton; }
}
public
RadButtonElement ModButton
{
get
{
return
this
.modButton; }
}
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
this
.mathStack =
new
StackLayoutElement();
this
.mathStack.Margin =
new
Padding(2, 25, 20, 2);
this
.mathStack.StretchHorizontally =
true
;
this
.sumButton =
new
RadButtonElement();
this
.sumButton.Text =
"Sum"
;
this
.sumButton.StretchHorizontally =
false
;
this
.mathStack.Children.Add(sumButton);
this
.divButton =
new
RadButtonElement();
this
.divButton.Text =
"Div"
;
this
.divButton.StretchHorizontally =
false
;
this
.mathStack.Children.Add(divButton);
this
.modButton =
new
RadButtonElement();
this
.modButton.Text =
"Mod"
;
this
.modButton.StretchHorizontally =
false
;
this
.mathStack.Children.Add(modButton);
this
.textBox =
new
RadTextBoxElement();
this
.textBox.StretchHorizontally =
true
;
this
.mathStack.Children.Add(textBox);
this
.Children.Add(mathStack);
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(GridHeaderCellElement);
}
}
}
And a sample usage:
void
radGridView1_CreateCell(
object
sender, GridViewCreateCellEventArgs e)
{
if
(e.Column.Name ==
"YourColumnName"
&& e.CellType ==
typeof
(GridHeaderCellElement))
{
e.CellType =
typeof
(MyHeaderCellElement);
}
}
Would you please clarify for me which arrow are you referring to. Please see if it is the one shown on the attached picture (arrow.png).
I hope this information be of use, looking forward to your reply.
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>