Telerik Winforms RadGrid Creating a Context Menu

Short code example for adding a Context Menu to a Telerik Winforms RadGrid. I've had this code in my library for years, but I'm writing this down today because I needed to make one of the items bold and that little piece of knowledge was hard to find. 

If you know an easier way, please LMK

 

Declare a global context menu

Dim mContextMenu = New RadContextMenu

Handle the 'context menu opening' event. Using this method, we can change the context menu based on the cell contents

Private Sub bothBidders_ContextMenuOpening(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.ContextMenuOpeningEventArgs) Handles grdBidders.ContextMenuOpening, grdBidders2.ContextMenuOpening
       Dim strError As String = ""
       Try
           mContextMenu.items.clear()
 
           'Open Specific Bidder Edit
           Dim menuItem1 As New RadMenuItem("Project Bidder Edit")
           'make the font bold
           Dim oFont As System.Drawing.Font = menuItem1.Font
           menuItem1.Font = New System.Drawing.Font(oFont.FontFamily, oFont.Size, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
           AddHandler menuItem1.Click, AddressOf OpenProjectBidderEdit
           mContextMenu.Items.Add(menuItem1)
 
           'Open Bidder Card
           Dim menuItem2 As New RadMenuItem("Open Bidder card")
           AddHandler menuItem2.Click, AddressOf OpenBidder
           mContextMenu.Items.Add(menuItem2)
 
           e.ContextMenu = mContextMenu.Dropdown
       Catch ex As Exception
           ErrorHandler.globalErrorHandler(ex, strError, App.AppName, App.UserName, True)
       End Try
   End Sub
   Sub OpenProjectBidderEdit()
       Dim strError As String = ""
       Try
           Dim strBidderID As String = Me.grdBidders.CurrentRow.Cells("BidderID").Value
           Dim strCompany1 As String = Me.grdBidders.CurrentRow.Cells("Company1").Value
           Dim frm As New ProjectBidderEdit(Me.txtTrackingNo.Text, strBidderID, strCompany1)
           Common.OpenFormInMiddleModal(frm)
           grdBiddersBind()
 
           setFormState(FormStateType.populated)
 
       Catch ex As Exception
           ErrorHandler.globalErrorHandler(ex, strError, App.AppName, App.UserName, True)
       End Try
 
   End Sub

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences