Help!! VB.NET Custom DataGridColumn Problem ...
-
I am having a problem with the datagrid. I needed a columnstyle to display a email link for each contact that is displayed in the detail portion of a master-detail form. I found an example of a combobox and modified it for to a linklabel (oddly enough it works ... this surprised me because I am completely lost with inherit, override, overload, etc. I think I'm down to two problems: I can't figure out how to handle the clicked link (this is kind of important!) and I would like to be able to change the background color of the label to match the alternating row color. Thanks in advance for any help provided!! Mark Here is the code for the datagridlinklabel: (sorry for the length) Option Strict On Option Explicit On Imports System.Collections Imports System.ComponentModel Imports System.Drawing Imports System.Windows.Forms Imports System.Data Public Class DataGridLinkLabel Inherits LinkLabel Public Sub New() MyBase.New() End Sub Public isInEditOrNavigateMode As Boolean = True End Class Public Class DataGridLinkLabelColumnStyle Inherits DataGridColumnStyle ' ' UI constants ' Private xMargin As Integer = 2 Private yMargin As Integer = 1 Private dgLinkLabel As DataGridLinkLabel ' ' Used to track editing state ' Private OldVal As String = String.Empty Private InEdit As Boolean = False ' ' Create a new column - DisplayMember passed by string ' Public Sub New(ByVal DisplayMember As String) dgLinkLabel = New DataGridLinkLabel() With dgLinkLabel .Visible = False .Text = DisplayMember End With End Sub Public Sub New() dgLinkLabel = New DataGridLinkLabel() With dgLinkLabel .Visible = False End With End Sub '------------------------------------------------------ ' Methods overridden from DataGridColumnStyle '------------------------------------------------------ ' ' Abort Changes ' Protected Overloads Overrides Sub Abort(ByVal RowNum As Integer) Debug.WriteLine("Abort()") RollBack() HideLinkLabel() EndEdit() End Sub Protected Overloads Overrides Function Commit(ByVal DataSource As CurrencyManager, _ ByVal RowNum As Integer) As Boolean HideLinkLabel() If Not InEdit Then Return True End If Try Dim Value