I have RadGridView and in that I have GridViewComboBoxColumn column (name is Comment). End user must select from the value for that column from GridViewComboBoxColumn list, or write the new value in that field. The problem is that when I write new value that isn't from list, after leaving that column new value not saved. Which option must i set in GridViewComboBoxColumn or other place.
Thank you..
3 Answers, 1 is accepted
0
Hello ,
Thank you for writing.
By default when a GridViewMultiComboBoxColumn is used, the value is synchronized with the items in the drop down. To achieve the desired behavior, you can use a text box column and change the editor. In addition, you should create a custom editor and return the entered text:
Let me know if I can assist you further.
Regards,
Dimitar
Telerik
Thank you for writing.
By default when a GridViewMultiComboBoxColumn is used, the value is synchronized with the items in the drop down. To achieve the desired behavior, you can use a text box column and change the editor. In addition, you should create a custom editor and return the entered text:
public
RadForm1()
{
InitializeComponent();
GridViewTextBoxColumn col =
new
GridViewTextBoxColumn();
col.Width = 300;
this
.radGridView1.Columns.Add(col);
for
(
int
i = 0; i < 10; i++)
{
radGridView1.Rows.AddNew();
}
radGridView1.EditorRequired += radGridView1_EditorRequired;
}
void
radGridView1_EditorRequired(
object
sender, EditorRequiredEventArgs e)
{
if
(radGridView1.CurrentColumn.Index == 0)
{
var element =
new
MyRadMultiColumnComboBoxElement();
element.ClearTextOnValidation =
false
;
element.BindingContext =
this
.BindingContext;
element.ClearTextOnValidation =
false
;
element.DataSource =
new
List<MyObject>
{
new
MyObject(
"comment1"
),
new
MyObject(
"comment2"
)
};
element.DisplayMember =
"Text"
;
element.ValueMember =
"Text"
;
e.Editor = element;
}
}
class
MyRadMultiColumnComboBoxElement : RadMultiColumnComboBoxElement
{
public
override
object
Value
{
get
{
return
this
.Text;
}
set
{
base
.Value = value;
}
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(RadMultiColumnComboBoxElement);
}
}
}
Let me know if I can assist you further.
Dimitar
Telerik
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 Feedback Portal and vote to affect the priority of the items
arezoo
commented on 30 Nov 2022, 11:22 AM
Top achievements
Rank 1
Dear dimitar can you convert these codes to vb.net for me??
I tried but couldn't.
Dinko | Tech Support Engineer
commented on 30 Nov 2022, 01:38 PM
Telerik team
Hi arezoo,
Here is the code from the reply converted to VB. You could consider using our online code converter which converts C# to VB and vice verse.
Public Sub New()
InitializeComponent()
Dim col As GridViewTextBoxColumn = New GridViewTextBoxColumn()
col.Width = 300
Me.radGridView1.Columns.Add(col)
For i As Integer = 0 To 10 - 1
radGridView1.Rows.AddNew()
Next
AddHandler radGridView1.EditorRequired, AddressOf radGridView1_EditorRequired
End Sub
Private Sub radGridView1_EditorRequired(ByVal sender As Object, ByVal e As EditorRequiredEventArgs)
If radGridView1.CurrentColumn.Index = 0 Then
Dim element = New MyRadMultiColumnComboBoxElement()
element.ClearTextOnValidation = False
element.BindingContext = Me.BindingContext
element.ClearTextOnValidation = False
element.DataSource = New List(Of MyObject) From {
New MyObject("comment1"),
New MyObject("comment2")
}
element.DisplayMember = "Text"
element.ValueMember = "Text"
e.Editor = element
End If
End Sub
Class MyRadMultiColumnComboBoxElement
Inherits RadMultiColumnComboBoxElement
Public Overrides Property Value As Object
Get
Return Me.Text
End Get
Set(ByVal value As Object)
MyBase.Value = value
End Set
End Property
Protected Overrides ReadOnly Property ThemeEffectiveType As Type
Get
Return GetType(RadMultiColumnComboBoxElement)
End Get
End Property
End Class
0

Grish
Top achievements
Rank 1
answered on 02 Feb 2016, 07:53 PM
Thank you Dimitar for your answer. I have resolved that problem with your answer. But i have other one.
void
radGridView1_CellEditorInitialized(
object
sender, GridViewCellEventArgs e)
{
RadMultiColumnComboBoxElement multiComboElement =
this
.radGridView1.ActiveEditor
as
RadMultiColumnComboBoxElement;
if
(multiComboElement !=
null
)
{
multiComboElement.EditorControl.MasterGridViewTemplate.BestFitColumns();
multiComboElement.AutoSizeDropDownToBestFit =
true
;
multiComboElement.DropDownSizingMode = SizingMode.UpDownAndRightBottom;
multiComboElement.AutoCompleteMode = AutoCompleteMode.None;
multiComboElement.DropDownStyle = RadDropDownStyle.DropDown;
multiComboElement.AutoFilter =
true
;
if
(multiComboElement.EditorControl.MasterGridViewTemplate.FilterExpressions.Count == 0)
{
FilterExpression autoFilter =
new
FilterExpression(multiComboElement.DisplayMember, FilterExpression.BinaryOperation.AND,
_inputmethod, GridFilterCellElement.ParameterName);
autoFilter.Parameters.Add(GridFilterCellElement.ParameterName,
""
);
multiComboElement.EditorControl.MasterGridViewTemplate.FilterExpressions.Add(autoFilter);
}
}
}
0
Hello ,
Thank you for writing back.
Could you please specify which version you are using? I am asking you this because I am unable to compile your code with the latest version.
In addition, I have tested this by enabling the AutoFilter functionality like described in the following article: Filtering. On my side, pressing Tab will keep the custom text, pressing Enter will select the item from the drop down. What is the exact behavior on your side?
I am looking forward to your reply.
Regards,
Dimitar
Telerik
Thank you for writing back.
Could you please specify which version you are using? I am asking you this because I am unable to compile your code with the latest version.
In addition, I have tested this by enabling the AutoFilter functionality like described in the following article: Filtering. On my side, pressing Tab will keep the custom text, pressing Enter will select the item from the drop down. What is the exact behavior on your side?
I am looking forward to your reply.
Regards,
Dimitar
Telerik
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 Feedback Portal and vote to affect the priority of the items