Ferry Engels
Top achievements
Rank 2
Ferry Engels
asked on 14 Feb 2011, 04:47 PM
Hello,
I have a question about the GridViewMultiComboBoxColumn editor.
I use 3 GridViewMultiComboBoxColumn(s) in my grid and i want all of them filled with 2 pull-down columns.
In the example on the site it is simple to get one GridViewMultiComboBoxColumn working.
But how do i get the other 2 filled. I tried to managed it by using there name in the code but that doesn't work.
Is there a simple way to fill them all.
The grid is created in code not in design-time.
Thanks
Ferry
I have a question about the GridViewMultiComboBoxColumn editor.
I use 3 GridViewMultiComboBoxColumn(s) in my grid and i want all of them filled with 2 pull-down columns.
In the example on the site it is simple to get one GridViewMultiComboBoxColumn working.
But how do i get the other 2 filled. I tried to managed it by using there name in the code but that doesn't work.
Is there a simple way to fill them all.
The grid is created in code not in design-time.
Thanks
Ferry
10 Answers, 1 is accepted
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 14 Feb 2011, 05:49 PM
Hello Ferry,
Adding additional columns will be the same as adding the first one.
Here is a sample for you that you can paste straight into a new project.
Designer File
Form1.cs
You might also be interested to see the documentation for this column type which can be found here
Hope that helps
Richard
Adding additional columns will be the same as adding the first one.
Here is a sample for you that you can paste straight into a new project.
Designer File
namespace
RadGridView_MultiComboColumn
{
partial
class
Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private
System.ComponentModel.IContainer components;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected
override
void
Dispose(
bool
disposing)
{
if
(disposing && (components !=
null
))
{
components.Dispose();
}
base
.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private
void
InitializeComponent()
{
this
.radGridView1 =
new
Telerik.WinControls.UI.RadGridView();
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).BeginInit();
this
.SuspendLayout();
//
// radGridView1
//
this
.radGridView1.BackColor = System.Drawing.SystemColors.Control;
this
.radGridView1.Cursor = System.Windows.Forms.Cursors.Default;
this
.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this
.radGridView1.Font =
new
System.Drawing.Font(
"Segoe UI"
, 8.25F);
this
.radGridView1.ForeColor = System.Drawing.SystemColors.ControlText;
this
.radGridView1.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this
.radGridView1.Location =
new
System.Drawing.Point(0, 0);
this
.radGridView1.Name =
"radGridView1"
;
this
.radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this
.radGridView1.Size =
new
System.Drawing.Size(464, 262);
this
.radGridView1.TabIndex = 0;
this
.radGridView1.Text =
"radGridView1"
;
//
// Form1
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.ClientSize =
new
System.Drawing.Size(464, 262);
this
.Controls.Add(
this
.radGridView1);
this
.Name =
"Form1"
;
this
.Text =
"Form1"
;
this
.Load +=
new
System.EventHandler(
this
.Form1_Load);
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).EndInit();
this
.ResumeLayout(
false
);
}
#endregion
private
Telerik.WinControls.UI.RadGridView radGridView1;
}
}
Form1.cs
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
using
Telerik.WinControls.UI;
namespace
RadGridView_MultiComboColumn
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
this
.radGridView1.AutoGenerateColumns =
false
;
// build cars data source
BindingList<Car> cars =
new
BindingList<Car>();
for
(
int
i = 0; i < 5;i++)
{
cars.Add(
new
Car(i,
"BMW 12"
+ i.ToString()));
}
// build schools data source
BindingList<School> schools =
new
BindingList<School>();
for
(
int
i = 0; i < 5; i++)
{
schools.Add(
new
School(i,
"School "
+ i.ToString()));
}
// build workplace data source
BindingList<Workplace> workplaces =
new
BindingList<Workplace>();
for
(
int
i = 0; i < 5; i++)
{
workplaces.Add(
new
Workplace(i,
"Workplace "
+ i.ToString()));
}
// build person data source
BindingList<Person> people =
new
BindingList<Person>();
for
(
int
i = 0; i < 5; i++)
{
people.Add(
new
Person(i,
"Name "
+ i.ToString(), i, i, i));
}
GridViewDecimalColumn idColumn =
new
GridViewDecimalColumn();
idColumn.HeaderText =
"PersonId"
;
idColumn.FieldName =
"Id"
;
idColumn.Name =
"Id"
;
GridViewTextBoxColumn nameColumn =
new
GridViewTextBoxColumn();
nameColumn.HeaderText =
"Name"
;
nameColumn.FieldName =
"Name"
;
nameColumn.Name =
"Name"
;
GridViewMultiComboBoxColumn carColumn =
new
GridViewMultiComboBoxColumn();
carColumn.DataSource = cars;
carColumn.HeaderText =
"Car"
;
carColumn.DisplayMember =
"Name"
;
carColumn.ValueMember =
"Id"
;
carColumn.FieldName =
"CarId"
;
GridViewMultiComboBoxColumn schoolColumn =
new
GridViewMultiComboBoxColumn();
schoolColumn.DataSource = schools;
schoolColumn.HeaderText =
"School"
;
schoolColumn.DisplayMember =
"Name"
;
schoolColumn.ValueMember =
"Id"
;
schoolColumn.FieldName =
"SchoolId"
;
GridViewMultiComboBoxColumn workplaceColumn =
new
GridViewMultiComboBoxColumn();
workplaceColumn.DataSource = workplaces;
workplaceColumn.HeaderText =
"Workplace"
;
workplaceColumn.DisplayMember =
"Name"
;
workplaceColumn.ValueMember =
"Id"
;
workplaceColumn.FieldName =
"WorkplaceId"
;
this
.radGridView1.Columns.Add(idColumn);
this
.radGridView1.Columns.Add(nameColumn);
this
.radGridView1.Columns.Add(carColumn);
this
.radGridView1.Columns.Add(schoolColumn);
this
.radGridView1.Columns.Add(workplaceColumn);
this
.radGridView1.DataSource = people;
}
}
public
class
Person
{
public
Person(
int
Id,
string
name,
int
carId,
int
schoolId,
int
workplaceId)
{
this
.Id = Id;
this
.Name = name;
this
.CarId = carId;
this
.SchoolId = schoolId;
this
.WorkplaceId = workplaceId;
}
public
int
Id
{
get
;
set
; }
public
string
Name
{
get
;
set
; }
public
int
CarId
{
get
;
set
; }
public
int
SchoolId
{
get
;
set
; }
public
int
WorkplaceId
{
get
;
set
; }
}
public
class
Car
{
public
Car(
int
Id,
string
name)
{
this
.Id = Id;
this
.Name = name;
}
public
int
Id
{
get
;
set
; }
public
string
Name
{
get
;
set
; }
}
public
class
School
{
public
School(
int
Id,
string
name)
{
this
.Id = Id;
this
.Name = name;
}
public
int
Id
{
get
;
set
; }
public
string
Name
{
get
;
set
; }
}
public
class
Workplace
{
public
Workplace(
int
Id,
string
name)
{
this
.Id = Id;
this
.Name = name;
}
public
int
Id
{
get
;
set
; }
public
string
Name
{
get
;
set
; }
}
}
You might also be interested to see the documentation for this column type which can be found here
Hope that helps
Richard
0
Ferry Engels
Top achievements
Rank 2
answered on 15 Feb 2011, 10:26 PM
Thanks Richard but it is not what i ment.
It is no problem to place more MultiComboBoxColums in my grid.
Also no problem to add a datasource to them.
But to get 2 columns when i click on the editor (just like the example were you are referring to) works in that example only on one MultiComboBoxColumn.
I want to fill all three MultiComboBoxColumns like that way.
I can't find any example to do that.
ps. my project is in VB
Ferry
It is no problem to place more MultiComboBoxColums in my grid.
Also no problem to add a datasource to them.
But to get 2 columns when i click on the editor (just like the example were you are referring to) works in that example only on one MultiComboBoxColumn.
I want to fill all three MultiComboBoxColumns like that way.
I can't find any example to do that.
ps. my project is in VB
Ferry
0
Richard Slade
Top achievements
Rank 2
answered on 15 Feb 2011, 10:57 PM
Hello Ferry,
Here is a VB exmaple as per the example at the link where it has more than one column as a multicolumncombo, each with two columns.
Designer File
Form1.vb
Hope that helps but let me know if you need more information
Richard
Here is a VB exmaple as per the example at the link where it has more than one column as a multicolumncombo, each with two columns.
Designer File
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial
Class
Form1
Inherits
System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected
Overrides
Sub
Dispose(
ByVal
disposing
As
Boolean
)
Try
If
disposing
AndAlso
components IsNot
Nothing
Then
components.Dispose()
End
If
Finally
MyBase
.Dispose(disposing)
End
Try
End
Sub
'Required by the Windows Form Designer
Private
components
As
System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private
Sub
InitializeComponent()
Me
.RadGridView1 =
New
Telerik.WinControls.UI.RadGridView()
CType
(
Me
.RadGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
Me
.SuspendLayout()
'
'RadGridView1
'
Me
.RadGridView1.Dock = System.Windows.Forms.DockStyle.Fill
Me
.RadGridView1.Location =
New
System.Drawing.Point(0, 0)
Me
.RadGridView1.Name =
"RadGridView1"
Me
.RadGridView1.Size =
New
System.Drawing.Size(383, 327)
Me
.RadGridView1.TabIndex = 0
Me
.RadGridView1.Text =
"RadGridView1"
'
'Form1
'
Me
.AutoScaleDimensions =
New
System.Drawing.SizeF(6.0!, 13.0!)
Me
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me
.ClientSize =
New
System.Drawing.Size(383, 327)
Me
.Controls.Add(
Me
.RadGridView1)
Me
.Name =
"Form1"
Me
.Text =
"Form1"
CType
(
Me
.RadGridView1, System.ComponentModel.ISupportInitialize).EndInit()
Me
.ResumeLayout(
False
)
End
Sub
Friend
WithEvents
RadGridView1
As
Telerik.WinControls.UI.RadGridView
End
Class
Form1.vb
Imports
Telerik.WinControls.UI
Imports
System.ComponentModel
Public
Class
Form1
Private
orderColumnAdded
As
Boolean
Private
devColumnAdded
As
Boolean
Private
Sub
Form1_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
Dim
orderList
As
New
BindingList(Of Order)()
orderList.Add(
New
Order(1234, 1))
orderList.Add(
New
Order(1324, 12))
orderList.Add(
New
Order(2345, 34))
Dim
devList
As
New
BindingList(Of DevEnv)()
devList.Add(
New
DevEnv(1,
"VS 2005"
))
devList.Add(
New
DevEnv(2,
"VS 2008"
))
devList.Add(
New
DevEnv(3,
"VS 2010"
))
Dim
people
As
New
BindingList(Of Person)()
people.Add(
New
Person(
"Richard"
, 1234, 3))
people.Add(
New
Person(
"Ferry"
, 2345, 2))
Dim
colName
As
GridViewTextBoxColumn =
New
GridViewTextBoxColumn()
colName.FieldName =
"Name"
colName.HeaderText =
"Name"
Me
.RadGridView1.Columns.Add(colName)
Dim
colOrder
As
GridViewMultiComboBoxColumn =
New
GridViewMultiComboBoxColumn()
colOrder.DataSource = orderList
colOrder.DisplayMember =
"Quantity"
colOrder.ValueMember =
"OrderID"
colOrder.FieldName =
"OrderID"
colOrder.HeaderText =
"Order Num"
Me
.RadGridView1.Columns.Add(colOrder)
Dim
colDev
As
GridViewMultiComboBoxColumn =
New
GridViewMultiComboBoxColumn()
colDev.DataSource = devList
colDev.DisplayMember =
"DevName"
colDev.ValueMember =
"DevId"
colDev.FieldName =
"DevId"
colDev.HeaderText =
"Dev Environment"
Me
.RadGridView1.Columns.Add(colDev)
AddHandler
RadGridView1.CellBeginEdit,
AddressOf
radGridView1_CellBeginEdit
Me
.RadGridView1.DataSource = people
End
Sub
Private
Sub
radGridView1_CellBeginEdit(
ByVal
sender
As
Object
,
ByVal
e
As
GridViewCellCancelEventArgs)
If
Me
.RadGridView1.CurrentColumn.Name =
"OrderId"
Then
If
(
Not
orderColumnAdded)
Then
orderColumnAdded =
True
Dim
editor
As
RadMultiColumnComboBoxElement =
CType
(
Me
.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
editor.EditorControl.MasterTemplate.AutoGenerateColumns =
False
editor.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"OrderID"
))
editor.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"Quantity"
))
editor.AutoSizeDropDownToBestFit =
True
End
If
End
If
If
Me
.RadGridView1.CurrentColumn.Name =
"DevId"
Then
If
(
Not
devColumnAdded)
Then
devColumnAdded =
True
Dim
editor
As
RadMultiColumnComboBoxElement =
CType
(
Me
.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
editor.EditorControl.MasterTemplate.AutoGenerateColumns =
False
editor.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"DevId"
))
editor.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"DevName"
))
editor.AutoSizeDropDownToBestFit =
True
End
If
End
If
End
Sub
End
Class
Public
Class
Order
Public
Sub
New
(
ByVal
orderId
As
Integer
,
ByVal
orderQty
As
Integer
)
Me
.OrderId = orderId
Me
.Quantity = orderQty
End
Sub
Public
Property
OrderId
As
Integer
Public
Property
Quantity
As
Integer
End
Class
Public
Class
DevEnv
Public
Sub
New
(
ByVal
devId
As
Integer
,
ByVal
devName
As
String
)
Me
.DevId = devId
Me
.DevName = devName
End
Sub
Public
Property
DevId
As
Integer
Public
Property
DevName
As
String
End
Class
Public
Class
Person
Public
Sub
New
(
ByVal
Name
As
String
,
ByVal
orderId
As
Integer
,
ByVal
devId
As
Integer
)
Me
.Name = Name
Me
.OrderId = orderId
Me
.DevId = devId
End
Sub
Public
Property
OrderId
As
Integer
Public
Property
DevId
As
Integer
Public
Property
Name
As
String
End
Class
Hope that helps but let me know if you need more information
Richard
0
Ferry Engels
Top achievements
Rank 2
answered on 16 Feb 2011, 12:18 AM
Richard,
Thank you for such a quick reply.
This is what i ment. But it works not the way it should be.
When i click on the first MultiComboBoxColumn i got 2 colums belonging to that MultiComboBoxColumn.
Then when i click on the second MultiComboBoxColumn i get 4 colums, 2 from the first (without data in it) and 2 from the MultiComboBoxColumn that i clicked on.
When i click on the first again it display also 4 columns (the other way around).
I followd the code in debug mode and the code works the way it should be.
Then i tried to clear the colums before filling them, that works but the next problem is that i get second time i clicked the same MultiComboBoxColumn i get a null reference error.
So i removed the flags and now it works because the colums are filled every time i click on them.
So now it is working but is this the right approuch. It feels not right do you now what i mean.
i included my code
But many thanks,
Ferry
Thank you for such a quick reply.
This is what i ment. But it works not the way it should be.
When i click on the first MultiComboBoxColumn i got 2 colums belonging to that MultiComboBoxColumn.
Then when i click on the second MultiComboBoxColumn i get 4 colums, 2 from the first (without data in it) and 2 from the MultiComboBoxColumn that i clicked on.
When i click on the first again it display also 4 columns (the other way around).
I followd the code in debug mode and the code works the way it should be.
Then i tried to clear the colums before filling them, that works but the next problem is that i get second time i clicked the same MultiComboBoxColumn i get a null reference error.
So i removed the flags and now it works because the colums are filled every time i click on them.
So now it is working but is this the right approuch. It feels not right do you now what i mean.
i included my code
But many thanks,
Ferry
Private
Sub
radGridView1_CellBeginEdit(
ByVal
sender
As
Object
,
ByVal
e
As
GridViewCellCancelEventArgs)
If
TypeOf
Me
.RadGridView1.CurrentColumn
Is
GridViewMultiComboBoxColumn
Then
If
Me
.RadGridView1.CurrentColumn.Name =
"CodeColumn"
Then
If
(
Not
isCodeColumnAdded)
Then
'isCodeColumnAdded = True
Dim
editor1
As
RadMultiColumnComboBoxElement =
CType
(
Me
.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
editor1.EditorControl.MasterTemplate.AutoGenerateColumns =
False
editor1.EditorControl.Columns.Clear()
editor1.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"FaktCode"
))
editor1.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"FaktRegel"
))
editor1.AutoSizeDropDownToBestFit =
True
End
If
End
If
If
Me
.RadGridView1.CurrentColumn.Name =
"KpltsColumn"
Then
If
(
Not
isKsPltsColumnAdded)
Then
'isKsPltsColumnAdded = True
Dim
editor2
As
RadMultiColumnComboBoxElement =
CType
(
Me
.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
editor2.EditorControl.MasterTemplate.AutoGenerateColumns =
False
editor2.EditorControl.Columns.Clear()
editor2.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"Kostenplaats"
))
editor2.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"Omschrijving"
))
editor2.AutoSizeDropDownToBestFit =
True
End
If
End
If
End
If
End
Sub
0
Richard Slade
Top achievements
Rank 2
answered on 16 Feb 2011, 01:21 AM
Hi Ferry,
Apologies. I should have picked that up. The reason for this is that the ActiveEditor already has the columns (the editors in RadGridView are re-used). You cannot clear them in this way. try clicking on the first row, first column, then the first row, second column, then the first row first column again. This throws a null reference exception.
I'm a little fried to continue tonight (it's after midnight here), but I'll look again in the morning for you. The documentation states about having this 'dirty' flag to ensure columns are not re-created, and in theory, this should be simple to get it working for more than one. I'll look again tomorrow when I'm a bit fresher. Sorry I couldn't get that sorted for you tonight.
Richard
Apologies. I should have picked that up. The reason for this is that the ActiveEditor already has the columns (the editors in RadGridView are re-used). You cannot clear them in this way. try clicking on the first row, first column, then the first row, second column, then the first row first column again. This throws a null reference exception.
I'm a little fried to continue tonight (it's after midnight here), but I'll look again in the morning for you. The documentation states about having this 'dirty' flag to ensure columns are not re-created, and in theory, this should be simple to get it working for more than one. I'll look again tomorrow when I'm a bit fresher. Sorry I couldn't get that sorted for you tonight.
Richard
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 16 Feb 2011, 10:24 AM
Hi Ferry,
ok, as you said you need to clear the columns. The RadGridView as I mentioned re-uses it's editors so using more than one it's required to clear them first. For reference, here is my example again which is now working correctly.
designer
If you think I can be of further help, please just let me know
Thanks
Richard
ok, as you said you need to clear the columns. The RadGridView as I mentioned re-uses it's editors so using more than one it's required to clear them first. For reference, here is my example again which is now working correctly.
Imports
Telerik.WinControls.UI
Imports
System.ComponentModel
Public
Class
Form1
Private
Sub
Form1_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
Dim
orderList
As
New
BindingList(Of Order)()
orderList.Add(
New
Order(1234, 1))
orderList.Add(
New
Order(1324, 12))
orderList.Add(
New
Order(2345, 34))
Dim
devList
As
New
BindingList(Of DevEnv)()
devList.Add(
New
DevEnv(1,
"VS 2005"
))
devList.Add(
New
DevEnv(2,
"VS 2008"
))
devList.Add(
New
DevEnv(3,
"VS 2010"
))
Dim
people
As
New
BindingList(Of Person)()
people.Add(
New
Person(
"Richard"
, 1234, 3))
people.Add(
New
Person(
"Ferry"
, 2345, 2))
Dim
colName
As
GridViewTextBoxColumn =
New
GridViewTextBoxColumn()
colName.FieldName =
"Name"
colName.HeaderText =
"Name"
Me
.RadGridView1.Columns.Add(colName)
Dim
colOrder
As
GridViewMultiComboBoxColumn =
New
GridViewMultiComboBoxColumn()
colOrder.DataSource = orderList
colOrder.DisplayMember =
"Quantity"
colOrder.ValueMember =
"OrderID"
colOrder.FieldName =
"OrderID"
colOrder.HeaderText =
"Order Num"
Me
.RadGridView1.Columns.Add(colOrder)
Dim
colDev
As
GridViewMultiComboBoxColumn =
New
GridViewMultiComboBoxColumn()
colDev.DataSource = devList
colDev.DisplayMember =
"DevName"
colDev.ValueMember =
"DevId"
colDev.FieldName =
"DevId"
colDev.HeaderText =
"Dev Environment"
Me
.RadGridView1.Columns.Add(colDev)
Me
.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
AddHandler
RadGridView1.CellBeginEdit,
AddressOf
radGridView1_CellBeginEdit
Me
.RadGridView1.DataSource = people
End
Sub
Private
Sub
radGridView1_CellBeginEdit(
ByVal
sender
As
Object
,
ByVal
e
As
GridViewCellCancelEventArgs)
If
TypeOf
RadGridView1.CurrentColumn
Is
GridViewMultiComboBoxColumn
Then
Dim
editor
As
RadMultiColumnComboBoxElement =
CType
(
Me
.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
editor.EditorControl.MasterTemplate.AutoGenerateColumns =
False
editor.EditorControl.Columns.Clear()
If
Me
.RadGridView1.CurrentColumn.Name =
"OrderID"
Then
editor.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"OrderID"
))
editor.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"Quantity"
))
End
If
If
Me
.RadGridView1.CurrentColumn.Name =
"DevId"
Then
editor.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"DevId"
))
editor.EditorControl.Columns.Add(
New
GridViewTextBoxColumn(
"DevName"
))
End
If
editor.AutoSizeDropDownToBestFit =
True
End
If
End
Sub
End
Class
Public
Class
Order
Public
Sub
New
(
ByVal
orderId
As
Integer
,
ByVal
orderQty
As
Integer
)
Me
.OrderId = orderId
Me
.Quantity = orderQty
End
Sub
Public
Property
OrderId
As
Integer
Public
Property
Quantity
As
Integer
End
Class
Public
Class
DevEnv
Public
Sub
New
(
ByVal
devId
As
Integer
,
ByVal
devName
As
String
)
Me
.DevId = devId
Me
.DevName = devName
End
Sub
Public
Property
DevId
As
Integer
Public
Property
DevName
As
String
End
Class
Public
Class
Person
Public
Sub
New
(
ByVal
Name
As
String
,
ByVal
orderId
As
Integer
,
ByVal
devId
As
Integer
)
Me
.Name = Name
Me
.OrderId = orderId
Me
.DevId = devId
End
Sub
Public
Property
OrderId
As
Integer
Public
Property
DevId
As
Integer
Public
Property
Name
As
String
End
Class
designer
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial
Class
Form1
Inherits
System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected
Overrides
Sub
Dispose(
ByVal
disposing
As
Boolean
)
Try
If
disposing
AndAlso
components IsNot
Nothing
Then
components.Dispose()
End
If
Finally
MyBase
.Dispose(disposing)
End
Try
End
Sub
'Required by the Windows Form Designer
Private
components
As
System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private
Sub
InitializeComponent()
Me
.RadGridView1 =
New
Telerik.WinControls.UI.RadGridView()
CType
(
Me
.RadGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
Me
.SuspendLayout()
'
'RadGridView1
'
Me
.RadGridView1.Dock = System.Windows.Forms.DockStyle.Fill
Me
.RadGridView1.Location =
New
System.Drawing.Point(0, 0)
Me
.RadGridView1.Name =
"RadGridView1"
Me
.RadGridView1.Size =
New
System.Drawing.Size(383, 327)
Me
.RadGridView1.TabIndex = 0
Me
.RadGridView1.Text =
"RadGridView1"
'
'Form1
'
Me
.AutoScaleDimensions =
New
System.Drawing.SizeF(6.0!, 13.0!)
Me
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me
.ClientSize =
New
System.Drawing.Size(383, 327)
Me
.Controls.Add(
Me
.RadGridView1)
Me
.Name =
"Form1"
Me
.Text =
"Form1"
CType
(
Me
.RadGridView1, System.ComponentModel.ISupportInitialize).EndInit()
Me
.ResumeLayout(
False
)
End
Sub
Friend
WithEvents
RadGridView1
As
Telerik.WinControls.UI.RadGridView
End
Class
If you think I can be of further help, please just let me know
Thanks
Richard
0
Ferry Engels
Top achievements
Rank 2
answered on 16 Feb 2011, 06:43 PM
Yes Richard, thank you.
I changed my code because your one is shorter.
Best Regards
Ferry
I changed my code because your one is shorter.
Best Regards
Ferry
0
Richard Slade
Top achievements
Rank 2
answered on 16 Feb 2011, 06:45 PM
Glad that helped
All the best
Richard
All the best
Richard
0
Ernez
Top achievements
Rank 1
answered on 01 Apr 2014, 08:35 AM
hi,
how can i use this FilterDescriptor with two GridViewMultiComboBoxColumn
i tried using this code but it fails when i click the second gridviewmulticomboboxcolumn the filter aren't working
[quote]Private Sub radGridView1_CellBeginEdit(ByVal sender As Object, ByVal e As GridViewCellCancelEventArgs) ' Handles RadGridView1.CellBeginEdit
If TypeOf Me.RadGridView1.CurrentColumn Is GridViewMultiComboBoxColumn Then
If RadGridView1.Columns.Item(Me.RadGridView1.CurrentColumn.Index).Name = "column1" Then
If (Not codeColumnAdded) Then
codeColumnAdded = True
Dim editor1 As RadMultiColumnComboBoxElement = CType(Me.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
editor1.EditorControl.Columns.Clear()
'If editor1.Rows.Count = 0 Then
'editor.EditorControl.MasterTemplate.AutoGenerateColumns = False
'editor.DataSource = DT_CHARTS
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("Code"))
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("Description"))
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("Type"))
editor1.AutoFilter = True
editor1.DisplayMember = "Description"
Dim filter As New FilterDescriptor()
filter.PropertyName = editor1.DisplayMember
filter.Operator = FilterOperator.Contains
editor1.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
editor1.DropDownSizingMode = SizingMode.UpDownAndRightBottom
editor1.AutoSizeDropDownToBestFit = True
'End If
End If
ElseIf RadGridView1.Columns.Item(Me.RadGridView1.CurrentColumn.Index).Name = "column2" Then
If (Not accColumnAdded) Then
accColumnAdded = True
Dim editor As RadMultiColumnComboBoxElement = CType(Me.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
editor.EditorControl.Columns.Clear()
'If editor.Rows.Count = 0 Then
'editor.EditorControl.MasterTemplate.AutoGenerateColumns = False
'editor.DataSource = DT_ACCOUNTS
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("AccountNo"))
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("AccName"))
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("Branch"))
editor.AutoFilter = True
editor.DisplayMember = "AccName"
Dim filter As New FilterDescriptor()
filter.PropertyName = editor.DisplayMember
filter.Operator = FilterOperator.Contains
editor.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
editor.DropDownSizingMode = SizingMode.UpDownAndRightBottom
editor.AutoSizeDropDownToBestFit = True
'End If
End If
End If
End If
End Sub
[/quote]
how can i use this FilterDescriptor with two GridViewMultiComboBoxColumn
i tried using this code but it fails when i click the second gridviewmulticomboboxcolumn the filter aren't working
[quote]Private Sub radGridView1_CellBeginEdit(ByVal sender As Object, ByVal e As GridViewCellCancelEventArgs) ' Handles RadGridView1.CellBeginEdit
If TypeOf Me.RadGridView1.CurrentColumn Is GridViewMultiComboBoxColumn Then
If RadGridView1.Columns.Item(Me.RadGridView1.CurrentColumn.Index).Name = "column1" Then
If (Not codeColumnAdded) Then
codeColumnAdded = True
Dim editor1 As RadMultiColumnComboBoxElement = CType(Me.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
editor1.EditorControl.Columns.Clear()
'If editor1.Rows.Count = 0 Then
'editor.EditorControl.MasterTemplate.AutoGenerateColumns = False
'editor.DataSource = DT_CHARTS
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("Code"))
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("Description"))
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("Type"))
editor1.AutoFilter = True
editor1.DisplayMember = "Description"
Dim filter As New FilterDescriptor()
filter.PropertyName = editor1.DisplayMember
filter.Operator = FilterOperator.Contains
editor1.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
editor1.DropDownSizingMode = SizingMode.UpDownAndRightBottom
editor1.AutoSizeDropDownToBestFit = True
'End If
End If
ElseIf RadGridView1.Columns.Item(Me.RadGridView1.CurrentColumn.Index).Name = "column2" Then
If (Not accColumnAdded) Then
accColumnAdded = True
Dim editor As RadMultiColumnComboBoxElement = CType(Me.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
editor.EditorControl.Columns.Clear()
'If editor.Rows.Count = 0 Then
'editor.EditorControl.MasterTemplate.AutoGenerateColumns = False
'editor.DataSource = DT_ACCOUNTS
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("AccountNo"))
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("AccName"))
'editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("Branch"))
editor.AutoFilter = True
editor.DisplayMember = "AccName"
Dim filter As New FilterDescriptor()
filter.PropertyName = editor.DisplayMember
filter.Operator = FilterOperator.Contains
editor.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
editor.DropDownSizingMode = SizingMode.UpDownAndRightBottom
editor.AutoSizeDropDownToBestFit = True
'End If
End If
End If
End If
End Sub
[/quote]
0
Hello Ernez,
Thank you for contacting us.
This solution is valid for the version it was created for (2010.3 10.1215). Currently, if you want to achieve similar behaviour you need to use the CellEditorInitialized event which is fired after the CellBeginEdit. For example you can set the datasource and add filter to the underlying grid with the following code:
Let me know if you have additional questions.
Regards,
Dimitar
Telerik
Thank you for contacting us.
This solution is valid for the version it was created for (2010.3 10.1215). Currently, if you want to achieve similar behaviour you need to use the CellEditorInitialized event which is fired after the CellBeginEdit. For example you can set the datasource and add filter to the underlying grid with the following code:
Private
Sub
radGridView1_CellEditorInitialized(sender
As
Object
, e
As
GridViewCellEventArgs)
If
TypeOf
Me
.radGridView1.CurrentColumn
Is
GridViewMultiComboBoxColumn
Then
If
radGridView1.Columns(
Me
.radGridView1.CurrentColumn.Index).Name =
"column1"
Then
Dim
editor1
As
RadMultiColumnComboBoxElement =
DirectCast
(
Me
.radGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
editor1.DataSource = GetTable()
editor1.EditorControl.EnableFiltering =
True
editor1.DisplayMember =
"Name"
Dim
filter
As
New
FilterDescriptor()
filter.PropertyName = editor1.DisplayMember
filter.[Operator] = FilterOperator.Contains
filter.Value =
"in"
editor1.EditorControl.FilterDescriptors.Add(filter)
editor1.DropDownSizingMode = SizingMode.UpDownAndRightBottom
editor1.AutoSizeDropDownToBestFit =
True
End
If
End
If
End
Sub
Let me know if you have additional 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.