This is a migrated thread and some comments may be shown as answers.

I Want Custom Cell In Gridview

2 Answers 58 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Shanti 😎
Top achievements
Rank 2
Veteran
Shanti 😎 asked on 05 Feb 2020, 06:46 AM

Hi,

I Want custom cell in RadGridview. For enter data and also arrow button to view popup like Figure 1.

I am looking forward to your reply.

Thanks.

2 Answers, 1 is accepted

Sort by
0
Shanti 😎
Top achievements
Rank 2
Veteran
answered on 06 Feb 2020, 07:30 AM

Hi,

I implemented this popup. Can you give me a better option?

Private Sub grdProduct_EditorRequired(sender As Object, e As EditorRequiredEventArgs) Handles grdProduct.EditorRequired
        If e.EditorType = GetType(RadTextBoxEditor) AndAlso grdProduct.CurrentColumn.Name = "Description" Then
            e.EditorType = GetType(MyEditor)
        End If
End Sub

Public Class MyEditor
    Inherits RadTextBoxEditor

    Protected Overrides Function CreateEditorElement() As Telerik.WinControls.RadElement
        Return New MyTextElement()
    End Function

    Public Overrides Sub BeginEdit()
        MyBase.BeginEdit()
        Dim oldValue As String = Me.Value.ToString()
        Me.EditorElement.Tag = oldValue
    End Sub
End Class


Public Class MyTextElement
    Inherits RadTextBoxEditorElement

    Public Sub New()
        Dim button As RadButtonElement = New RadButtonElement()
        AddHandler button.Click, AddressOf button_Click

        button.Padding = New Padding(2, 0, 2, -2)
        button.Margin = New Padding(0, 0, 0, 0)
        button.Text = "▼"

        Dim tbItem As RadTextBoxItem = Me.TextBoxItem
        Me.Children.Remove(tbItem)

        Dim dockPanel As DockLayoutPanel = New DockLayoutPanel()
        dockPanel.Children.Add(button)
        dockPanel.Children.Add(tbItem)

        DockLayoutPanel.SetDock(tbItem, Dock.Left)
        DockLayoutPanel.SetDock(button, Dock.Right)
        Me.Children.Add(dockPanel)

    End Sub

    Private Sub button_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim rtxtboxitem As RadTextBoxItem = CType(sender, RadButtonElement).Parent.Children(1)

        Dim frm As New frmDescription
        frm.txtDescription.Text = rtxtboxitem.Text
        frm.Location = frmInvoice.grdProduct.CurrentCell.PointToScreen(frmInvoice.grdProduct.CurrentCell.Location)
        If frm.ShowDialog = DialogResult.OK Then
            rtxtboxitem.Text = frm.txtDescription.Text
        End If
    End Sub

End Class

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Feb 2020, 09:56 AM
Hello, Shanti,   

I have changed the product of this support ticket to RadGridView, since it was specified as RadMenu. The provided screenshot is greatly appreciated for understanding better your requirement for an editor in RadGridView

Following the provided code snippet, I was able to build a runnable project and successfully embedded the custom editor in the grid. It seems to work as expected on my end.

I would recommend you to have a look at the following KB articles which demonstrate two approaches which may be suitable for your case:
https://www.telerik.com/support/kb/winforms/gridview/details/create-pop-up-user-control-for-row-editing 
https://docs.telerik.com/devtools/winforms/knowledge-base/edit-a-cell-in-gridview-with-a-dialog 

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Menu
Asked by
Shanti 😎
Top achievements
Rank 2
Veteran
Answers by
Shanti 😎
Top achievements
Rank 2
Veteran
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or