Dear all
I have a question
how do all this syntax in GVMCCB ?
Private Sub CMMBCustomer_CustomFiltering(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCustomFilteringEventArgs)
Dim element As RadMultiColumnComboBoxElement = MCCBCustomer.MultiColumnComboBoxElement
Dim textToSearch As String = MCCBCustomer.Text
If AutoCompleteMode.Append = (element.AutoCompleteMode And AutoCompleteMode.Append) Then
If element.SelectionLength > 0 AndAlso element.SelectionStart > 0 Then
textToSearch = MCCBCustomer.Text.Substring(0, element.SelectionStart)
End If
End If
If String.IsNullOrEmpty(textToSearch) Then
e.Visible = True
For i As Integer = 0 To element.EditorControl.ColumnCount - 1
e.Row.Cells(i).Style.Reset()
Next
e.Row.InvalidateRow()
Return
End If
e.Visible = False
For i As Integer = 0 To element.EditorControl.ColumnCount - 1
Dim text As String = e.Row.Cells(i).Value.ToString()
If text.IndexOf(textToSearch, 0, StringComparison.InvariantCultureIgnoreCase) >= 0 Then
e.Visible = True
e.Row.Cells(i).Style.CustomizeFill = True
e.Row.Cells(i).Style.DrawFill = True
e.Row.Cells(i).Style.BackColor = Color.FromArgb(201, 252, 254)
Else
e.Row.Cells(i).Style.Reset()
End If
Next
e.Row.InvalidateRow()
End Sub
Private Sub CMMBCustomer_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
With MCCBCustomer
If e.KeyCode = System.Windows.Forms.Keys.Enter Then
If .ValueMember <> "" Then
.SelectedValue = .EditorControl.CurrentRow.Cells(.ValueMember).Value
Else
.SelectedValue = .EditorControl.CurrentRow.Cells(.DisplayMember).Value
End If
.Text = .EditorControl.CurrentRow.Cells(.DisplayMember).Value.ToString()
.MultiColumnComboBoxElement.ClosePopup()
.MultiColumnComboBoxElement.TextBoxElement.TextBoxItem.SelectAll()
End If
End With
End Sub
Private Sub CMMBCustomer_DropDownClosed(ByVal sender As Object, ByVal args As Telerik.WinControls.UI.RadPopupClosedEventArgs) Handles MCCBCustomer.DropDownClosed
If MCCBCustomer.SelectedIndex <> -1 Then
LblNamaCustomer.Text = MCCBCustomer.EditorControl.Rows(MCCBCustomer.SelectedIndex).Cells(1).Value.ToString
Else
LblNamaCustomer.Text = ""
End If
End Sub
Private Sub CMMBCustomer_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MCCBCustomer.Validated
If MCCBCustomer.Text = "" Then
LblNamaCustomer.Text = ""
End If
End Sub
Thanks before...
32 Answers, 1 is accepted
Thank you for writing.
Note that you can handle the RadGridView.CellEditorInitialized event which is fired once the editor is initialized. This is the place where you have access to the RadMultiColumnComboBoxElement and you can subscribe to any of the desired events that you want to use:
Private
Sub
Form1_Load(sender
As
Object
, e
As
EventArgs)
Handles
MyBase
.Load
Me
.ProductsTableAdapter.Fill(
Me
.NwindDataSet.Products)
Me
.CategoriesTableAdapter.Fill(
Me
.NwindDataSet.Categories)
Me
.RadGridView1.DataSource = ProductsBindingSource
Dim
col
As
GridViewMultiComboBoxColumn =
New
GridViewMultiComboBoxColumn(
"Category"
)
col.DataSource =
Me
.CategoriesBindingSource
col.DisplayMember =
"CategoryName"
col.ValueMember =
"CategoryID"
col.FieldName =
"CategoryID"
Me
.RadGridView1.Columns.Add(col)
AddHandler
Me
.RadGridView1.CellEditorInitialized,
AddressOf
CellEditorInitialized
End
Sub
Private
Sub
CellEditorInitialized(sender
As
Object
, e
As
GridViewCellEventArgs)
Dim
mccb
As
RadMultiColumnComboBoxElement = TryCast(e.ActiveEditor, RadMultiColumnComboBoxElement)
If
mccb IsNot
Nothing
Then
RemoveHandler
mccb.KeyDown,
AddressOf
mccb_KeyDown
AddHandler
mccb.KeyDown,
AddressOf
mccb_KeyDown
End
If
End
Sub
Private
Sub
mccb_KeyDown(sender
As
Object
, e
As
KeyEventArgs)
Console.WriteLine(e.KeyData)
End
Sub
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik by Progress
Hello Dess
Thanks for fast respone... i will try it first ...
thanks You very much
Thank you for writing back.
In order to populate the RadMultiColumnComboBoxElement in the GridViewMultiComboBoxColumn with data, you can set the GridViewMultiComboBoxColumn.DataSource property to the desired collection. Additional information how to setup the columns is available here: http://docs.telerik.com/devtools/winforms/gridview/columns/column-types/gridviewmulticomboboxcolumn
After making a selection in the editor, you can set the value for another cell on the same row. Here is a sample code snippet which result is illustrated in the attached gif file:
Me
.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
Private
Sub
ValueChanged(sender
As
Object
, e
As
EventArgs)
Dim
mccb
As
RadMultiColumnComboBoxElement = TryCast(
Me
.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
If
mccb IsNot
Nothing
Then
Dim
rowInfo
As
GridViewDataRowInfo = TryCast(mccb.SelectedItem, GridViewDataRowInfo)
Me
.RadGridView1.CurrentRow.Cells(
"CategoryID"
).Value = rowInfo.Cells(
"CategoryID"
).Value
End
If
End
Sub
As to the filtering functionality, you can refer to the following example. Thus, when typing in the editor, the popup grid is filtered:
AddHandler
Me
.RadGridView1.CellEditorInitialized,
AddressOf
CellEditorInitialized
Private
Sub
CellEditorInitialized(sender
As
Object
, e
As
GridViewCellEventArgs)
Dim
mccb
As
RadMultiColumnComboBoxElement = TryCast(e.ActiveEditor, RadMultiColumnComboBoxElement)
If
mccb IsNot
Nothing
Then
mccb.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown
mccb.AutoFilter =
True
If
mccb.EditorControl.FilterDescriptors.Count = 0
Then
Dim
filter
As
New
FilterDescriptor()
filter.PropertyName = mccb.DisplayMember
filter.Operator = FilterOperator.Contains
mccb.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
End
If
End
If
End
Sub
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik by Progress
Halllo dess Many thanks to you it's work fine...
Thanks..
Hello dess... ?
i've tried the code you wrote why it doesn't work for me ?
Private Sub ValueChanged(sender As Object, e As EventArgs)
Dim mccb As RadMultiColumnComboBoxElement = TryCast(Me.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
If mccb IsNot Nothing Then
Dim rowInfo As GridViewDataRowInfo = TryCast(mccb.SelectedItem, GridViewDataRowInfo)
Me.RadGridView1.CurrentRow.Cells("CategoryID").Value = rowInfo.Cells("CategoryID").Value
End If
End Sub
how to call this sub ?
Thanks before
Hai Dess
or how access dropdownclosed in gridviewmulticolumncombobox....
"Me.RadGridView1.CurrentRow.Cells("CategoryID").Value = rowInfo.Cells("CategoryID").Value" i need this code run when dropdwonclosed
Thanks
Thank you for writing.
The ValueChanged event in RadGridView is fired when you change the value in the editor. RadMultiColumnComboBoxElement automatically closed its popup when a row is selected in the inner grid. Then, the ValueChanged event will be fired and the value of the neighboring cell will be updated accordingly.
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik
Hai Dess
Can i have the code for changevalue.gif ?
Because i have tried wrote snippet code you give to james, and it doesn't work.on me ..
Thanks before.
I mean full coding not a snippet code...
:D
Tq before dess
Thank you for writing back.
I have attached a sample project for your reference.
I would kindly ask you to use our support ticketing system for any further inquiries that you have. Thus, all your threads will be handled by our support staff according to license and time of posting.
Thank you for your understanding.
Regards,
Dess
Progress Telerik
Tq dess for writing back and for the solution
but i need the categoriID selected or can be change through gridmccb. not categori name.
one more, why its very slow ? when fill data to gridmccb.
Thanks dess
Best Regards
Hengky
Hai Dess thanks for writing back
how if i need to change the category id, not the category name.
your example is change the categoryname, what i need is change the CategoryId on Product table
thanks before
* i will mentioned about licensing.
Thank you for writing back.
It is up to you for which field you will add the GridViewMultiComboBoxColumn. It is necessary to specify the column's FieldName property (e.g. "CategoryID") and populate it with data (by the DataSource property). Then, in the RadGridView.ValueChanged event you can manipulate each cell value according to your custom requirement.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Progress Telerik
Thank you for writing back.
I was not able to replicate the issue with my sample project. However, according to the error message, I suppose that you have only constructors with parameters in your custom object. In this case, the parameterless constructor is required by our implementation in RadGridView to create a new instance of the class and populate the data according to the data in the columns. So in order to be able to add new rows you need to add a parameterless constructor as well.
If it is not the case, feel free to submit a support ticket where you can provide a sample project demonstrating the undesired behavior. Thus, our support staff will gladly assist you.
I hope this information helps.
Regards,
Dess
Progress Telerik
Hai dess... sorry for late reply....
how to make this happen if i use Entity Framework for fill the col ...
For Each s In query_detail
RadGridView1.Rows.Add(s.Kode, s.NamaBarang, s.Qtty, s.Harga, s.Nilai)
Next
Dim col As GridViewMultiComboBoxColumn = New GridViewMultiComboBoxColumn("KodeBarang")
Dim SqlBarang = From Barang In db.MstBarangs
Select New With {Barang.KodeBarang, Barang.NamaBarang}
col.DataSource = SqlBarang.ToList
col.DisplayMember = "NamaBarang"
col.ValueMember = "KodeBarang"
col.MinWidth = 100
col.FieldName = "KodeBarang"
Me.RadGridView1.Columns.Add(col)
the code working fine, but with one miss ... it doesn't want to show the NamaBarang for the first time
You can check the following resources discussing in details how you can bind the grid using Entity Framework:
- https://docs.telerik.com/devtools/winforms/gridview/populating-with-data/binding-to-entityframework-using-database-first-approach
- https://www.telerik.com/support/kb/winforms/gridview/details/binding-radgridview-to-entity-framework-using-code-first-approach
From your code snippet, it appears that you are doing a select which returns anonymous types. Please avoid this as the grid would not be editable. This behavior can also be observed with the standard .NET grid control. The following articles provide more information on that matter:
- https://blogs.msdn.microsoft.com/swiss_dpe_team/2008/01/25/using-your-own-defined-type-in-a-linq-query-expression/
- https://stackoverflow.com/questions/3474531/linq-and-how-to-return-a-list-of-a-specific-type
I hope this information was useful.
Regards,
Hristo
Progress Telerik
Hello Hristo, thanks for writing back...
i already bind the grid from EF. the blank column on the picture is MultiColumnComboBox... that fill with data to like example from Dess. ( if i use ado.net binding, its very well working)
How make this happen with EF.. ?
Binding the GridViewMultiComboBoxColumn to Entity Framework should not be much different compared to the grid. As demonstrated in the grid`s article please make sure that you load the collection in the DbContext and then access it through the Local property like this:
col.DataSource = dbContext.Orders.Local.ToBindingList();
As I said before, please also make sure that you do not bind to a collection of anonymous types. In case you need further assistance, please open a support ticket and send us your project so that we can investigate it locally.
Let me know if you have other questions.
Regards,
Hristo
Progress Telerik
After return to telerik again .. i have facing this problem ...
The prog running very slowly ....
on selected data in gridviewcolumncombobox
Dim dsBagian As New DataSet
Using conn As New SqlConnection(str)
conn.Open()
da = New SqlDataAdapter("SELECT KodeBarang, NamaBarang FROM MstBarang " &
"ORDER BY KodeBarang", conn)
dsBagian = New DataSet
dsBagian.Clear()
da.Fill(dsBagian, "Barang")
da.Dispose()
conn.Close()
End Using
Dim col As GridViewMultiComboBoxColumn = New GridViewMultiComboBoxColumn("KodeBarang")
col.DataSource = dsBagian.Tables("Barang")
col.DisplayMember = "KodeBarang"
col.MinWidth = 100
col.ValueMember = "KodeBarang"
col.FieldName = "KodeBarang"
col.HeaderText = "Kode Barang"
Me.RadGridView1.Columns.Add(col)
Me.RadGridView1.Columns.Add(New GridViewTextBoxColumn("NamaBarang"))
Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
RadGridView1.AutoGenerateColumns = False
AddHandler Me.RadGridView1.ValueChanged, AddressOf ValueChanged
AddHandler Me.RadGridView1.CellEditorInitialized, AddressOf CellEditorInitialized
AddHandler RadGridView1.CellBeginEdit, AddressOf radGridView1_CellBeginEdit
Hello, Hengky,
According to the provided code snippet, it seems that you are extracting the data from a database. I suspect that this takes most of the time. It would be good to detect how much time the DataSet population takes.
I have created a project with a GridViewMultiComboBoxColumn bound to Northwind.Categories table. It is bound immediately on my end. I have attached my sample project. Could you please specify the exact steps how to reproduce the problem with it?
Feel free to submit a support ticket from your Telerik account where you can provide a sample project demonstrating the performance problem that you are facing. Thus, we would be able to make an adequate analysis of the precise case and provide further assistance. Thank you in advance.
I am looking forward to your reply.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Hai dess
I have created the project from the example that u gave to me long years ago ...
i have still facing the same problem .... because of this I tried the other product ... hehehehe....
it's have faster performance then telerik ... with the same code ... but telerik have more friendly in GUI development ...
actually i just need to make in line add data with gridview ...
Hope u understand what i mean ...
Hi, Hengky,
Without replicating the issue locally, we can make only conjectures what causes the undesired slow loading on your end. Have you tried to run my sample project? Is it loaded as expected on your end? I would suggest you to detect how much time the DataSet population takes on your end. How many record do you have in the DataSet?
Would it be possible to submit a support ticket from your Telerik account and provide a runnable sample project demonstrating the undesired behavior that you are facing? If it would be easier for you, feel free to modify the previously provided sample project.
Once we replicate the issue locally, we would be able to investigate the precise case and think about a suitable solution.
An alternative solution that is worth considering is using a RadPopupEditor and hosting either RadGridView in the popup container or a RadVirtualGrid.
The following example demonstrates how to get started with the RadPopupEditor and host the desired controls in the container: https://docs.telerik.com/devtools/winforms/controls/editors/popupeditor/getting-started
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
hello dess ...
i just need to make this ...
I have 9k rows...
so to make faster i made the search form i called "frmCari"
if it's blank or hit commandcell it will open frmCari ...
on "OK" click it will return the value of column 1 & 2 in FrmCari
what i get is, always error if the row blank .... (or new state)
Thanks dess
According to the provided information, it is not clear what is the exact implementation that you have on your end and why the error message occurs. Could you please specify the exact steps how to reproduce the problem?
It would be greatly appreciated if you can provide a complete code snippet related to the two forms illustrated on your screenshot. Thus, we would be able to replicate the undesired behavior locally and investigate further what happens.
Thank you in advance for your cooperation. I am looking forward to your reply.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Hai dess
finally i found the solution for my self
just simple code
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
If baris = -1 Then
RadGridView1.Rows.Add("baru")
Else
RadGridView1.Rows(baris).Cells(0).Value = RadTextBox1.Text
End If
end sub
Hai Dess ... this the code ...
Public Class Form1
Private isColumnAdded As Boolean
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim dsBagian As New DataSet
Using conn As New SqlConnection(str)
conn.Open()
da = New SqlDataAdapter("SELECT KodeBarang, NamaBarang FROM MstBarang " &
"ORDER BY KodeBarang", conn)
dsBagian = New DataSet
dsBagian.Clear()
da.Fill(dsBagian, "Barang")
da.Dispose()
conn.Close()
End Using
Dim col As GridViewMultiComboBoxColumn = New GridViewMultiComboBoxColumn("KodeBarang")
col.DataSource = dsBagian.Tables("Barang")
col.DisplayMember = "KodeBarang"
col.MinWidth = 100
col.ValueMember = "KodeBarang"
col.FieldName = "KodeBarang"
col.HeaderText = "Kode Barang"
Me.RadGridView1.Columns.Add(col)
Me.RadGridView1.Columns.Add(New GridViewTextBoxColumn("NamaBarang"))
AddHandler Me.RadGridView1.ValueChanged, AddressOf ValueChanged
AddHandler Me.RadGridView1.CellEditorInitialized, AddressOf CellEditorInitialized
AddHandler RadGridView1.CellBeginEdit, AddressOf radGridView1_CellBeginEdit
End Sub
Private Sub radGridView1_CellBeginEdit(ByVal sender As Object, ByVal e As GridViewCellCancelEventArgs)
If TypeOf Me.RadGridView1.CurrentColumn Is GridViewMultiComboBoxColumn Then
If (Not isColumnAdded) Then
isColumnAdded = True
Dim editor As RadMultiColumnComboBoxElement = CType(Me.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
editor.EditorControl.MasterTemplate.AutoGenerateColumns = False
editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("KodeBarang"))
editor.EditorControl.Columns.Add(New GridViewTextBoxColumn("NamaBarang"))
editor.DropDownWidth = 300
editor.AutoSizeDropDownToBestFit = True
editor.Columns("NamaBarang").AllowResize = True
End If
End If
End Sub
Private Sub ValueChanged(sender As Object, e As EventArgs)
Dim mccb As RadMultiColumnComboBoxElement = TryCast(Me.RadGridView1.ActiveEditor, RadMultiColumnComboBoxElement)
If mccb IsNot Nothing Then
Dim rowInfo As GridViewDataRowInfo = TryCast(mccb.SelectedItem, GridViewDataRowInfo)
Me.RadGridView1.CurrentRow.Cells("KodeBarang").Value = rowInfo.Cells("KodeBarang").Value
End If
End Sub
Private Sub CellEditorInitialized(sender As Object, e As GridViewCellEventArgs)
Dim mccb As RadMultiColumnComboBoxElement = TryCast(e.ActiveEditor, RadMultiColumnComboBoxElement)
If mccb IsNot Nothing Then
mccb.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown
mccb.AutoFilter = True
If mccb.EditorControl.FilterDescriptors.Count = 0 Then
Dim filter As New FilterDescriptor()
filter.PropertyName = mccb.DisplayMember
filter.Operator = FilterOperator.Contains
mccb.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
End If
End If
End Sub
End Class
I have 9k row data in "Barang"
Following the provided code snippet, I have updated my sample project. It seems that you are using the filtering functionality in the GridViewMultiComboBoxColumn. Indeed, with 9000 rows in the RadMultiColumnComboBoxElement editor, there is a slight delay because the filtering is performed on each key stroke and there are a lot of records to iterate and find the matches.
Since R2 2017 version, you can improve the user experience with cursor lagging while filtering in the editor. In the CellEditorInitialized event you can set the RadMultiColumnComboBoxElement.AutoFilterDelay property to 1000 for example. Thus, you can specify the value in milliseconds indicating delay between last key press and filtering operation.
Private Sub CellEditorInitialized(sender As Object, e As GridViewCellEventArgs)
Dim mccb As RadMultiColumnComboBoxElement = TryCast(e.ActiveEditor, RadMultiColumnComboBoxElement)
If mccb IsNot Nothing Then
mccb.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown
mccb.AutoFilter = True
If mccb.EditorControl.FilterDescriptors.Count = 0 Then
Dim filter As New FilterDescriptor()
filter.PropertyName = mccb.DisplayMember
filter.Operator = FilterOperator.Contains
mccb.EditorControl.MasterTemplate.FilterDescriptors.Add(filter)
mccb.AutoFilterDelay = 1000
End If
End If
End Sub
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Hai dess i have tried the code you give to me.
but the performance not increase so much ....
because of this, i use to call the commandcell to open the searching form ... and return to the source form ... it's better performace..
and the problem .... how to call this :
Private Sub GridDetail_CommandCellClick(sender As Object, e As GridViewCellEventArgs) Handles GridDetail.CommandCellClick
baris = GridDetail.CurrentRow.Index
ParamForm = "TrTerimaBarangEntri"
Dim frm As New FrmCari
Select Case e.Column.Name
Case "BtnCariBarangGrid"
frm.Text = "BarangGrid"
End Select
SettingFrmCari(frm)
frm.ShowDialog()
End Sub
when column "kode"(radgridview column index no1) validating ( i mean when it empty string, or hit enter, something like that ... )
Thanks dess
Hello, Hengky,
To be honest, using a separate form with a RadGridView that uses its search row for finding the matches is the best possible performance that you can get. RadGridView internally uses a BackgroundWorker for its search functionality and it produces quite good performance.
The following KB article demonstrates a sample approach how to edit a row in the grid via a dialog: https://docs.telerik.com/devtools/winforms/knowledge-base/edit-a-cell-in-gridview-with-a-dialog You can use a similar approach and build any custom dialog that you would need for covering your scenario.
Should you have further questions please let me know.Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Hai dess ....
Thank You So Much for the help ...
Best Regards....