Hello,
I work with radGridView in unbound mode and every time I add a column I want to add a Tag to it, indicating the object that the column derives from. However, there is no such property as Tag for columns. Is there a possible way to achieve this, like binding a property or something like this? I tried to add the object's key in gridView.Columns[index].Name property, but this has as a result the uniqueness of the columns. Please help.
Thank you in advance
George K.
I work with radGridView in unbound mode and every time I add a column I want to add a Tag to it, indicating the object that the column derives from. However, there is no such property as Tag for columns. Is there a possible way to achieve this, like binding a property or something like this? I tried to add the object's key in gridView.Columns[index].Name property, but this has as a result the uniqueness of the columns. Please help.
Thank you in advance
George K.
9 Answers, 1 is accepted
0

Richard Slade
Top achievements
Rank 2
answered on 21 Oct 2010, 02:45 PM
Hi,
I'm unsure as to how you intend to use this tag, but if you just want somewhere to store a value, and if you don't have any NULL values in your data, you could use the Null Value property of the column
E.g -
is this the sort of thing you mean?
Richard
I'm unsure as to how you intend to use this tag, but if you just want somewhere to store a value, and if you don't have any NULL values in your data, you could use the Null Value property of the column
E.g -
Me
.RadGridView.Columns(0).NullValue =
"Namespace.Class"
is this the sort of thing you mean?
Richard
0

Richard Slade
Top achievements
Rank 2
answered on 21 Oct 2010, 02:49 PM
Or, you could put a tag on the cell itself
Best regards,
Richard
Private
Sub
RadGridView1_CellFormatting(
ByVal
sender
As
System.
Object
,
ByVal
e
As
Telerik.WinControls.UI.CellFormattingEventArgs)
Handles
RadGridView1.CellFormatting
If
e.CellElement.ColumnInfo.HeaderText =
"SOME HEADER"
Then
e.CellElement.Tag =
"My Tag"
End
If
End
Sub
Richard
0

Georgios
Top achievements
Rank 1
answered on 21 Oct 2010, 02:53 PM
Yes Richard, this is exactly the sort of thing I mean, but I do have null values and as a result NullValues property is not suitable. The point is that the cells have their own tag in which their own id is stored and as a result I cant' use it for the columns.
0

Richard Slade
Top achievements
Rank 2
answered on 21 Oct 2010, 02:57 PM
and the second suggestion?
EDIT: Oops, just re-read your post
EDIT: Oops, just re-read your post
0

Richard Slade
Top achievements
Rank 2
answered on 21 Oct 2010, 03:07 PM
However, the tag value accepts object so it could be anything. You can store arrays or list of values in it if you want
Richard
Private
Sub
RadGridView1_CellFormatting(
ByVal
sender
As
System.
Object
,
ByVal
e
As
Telerik.WinControls.UI.CellFormattingEventArgs)
Handles
RadGridView1.CellFormatting
If
e.CellElement.ColumnInfo.HeaderText =
"SOME HEADER"
Then
Dim
tagvalues
As
New
System.Collections.Generic.List(Of
String
)
tagValues.Add(
"Column Tag"
)
tagValues.Add(
"Cell Tag"
)
e.CellElement.Tag = tagvalues
End
If
End
Sub
0
Accepted

Emanuel Varga
Top achievements
Rank 1
answered on 21 Oct 2010, 05:38 PM
Hello guys,
Georgios, sadly currently the Column does not have a tag property, but if i may, i would suggest creating a Dictionary<int, Type> with the column index as the key and the type, and add that to the main grid's Tag, you will always know the grid it came from, and the column index, so it would be very easy to use and understand.
At least in my point of view.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Georgios, sadly currently the Column does not have a tag property, but if i may, i would suggest creating a Dictionary<int, Type> with the column index as the key and the type, and add that to the main grid's Tag, you will always know the grid it came from, and the column index, so it would be very easy to use and understand.
At least in my point of view.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0

Georgios
Top achievements
Rank 1
answered on 22 Oct 2010, 07:34 AM
I believe the creation of a dictionary is the best approach for now. Thank you both for your time.
Regards,
George
Regards,
George
0

Emanuel Varga
Top achievements
Rank 1
answered on 22 Oct 2010, 07:35 AM
Hello Georgios,
Glad to be able to help, if you have any more questions please just let me know, and if the question has been solved, please mark the question as answered, so that others can find the answers to their questions faster.
Best Regards,
Emanuel Varga
Glad to be able to help, if you have any more questions please just let me know, and if the question has been solved, please mark the question as answered, so that others can find the answers to their questions faster.
Best Regards,
Emanuel Varga
1
Hi Georgios,
Then you can use it simply by using the GetValue and SetValue methods of the column:
Svett
the Telerik team
There is another way to add the Tag property for your column. You can use the advanced features of the property system in Telerik Presentation Framework.
You can define a RadProperty that you can attach to the specified column:
public
class
ColumnProperties
{
public
static
readonly
RadProperty TagProperty =
RadProperty.Register(
"Tag"
,
typeof
(
object
),
typeof
(GridViewDataColumn),
new
RadPropertyMetadata(
null
));
}
Then you can use it simply by using the GetValue and SetValue methods of the column:
this
.radGridView1.Columns[0].SetValue(ColumnProperties.TagProperty,
"Telerik"
);
string
value =
this
.radGridView1.Columns[0].GetValue(ColumnProperties.TagProperty)
as
string
;
I hope this helps.
Svett
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