Public Class frmMain
Public objSenderName As System.Object
Public transparentImage As Bitmap
Public Class NoEllipsisColumn
Inherits DataGridViewTextBoxColumn
Public Overrides Property CellTemplate() As System.Windows.Forms.DataGridViewCell
Get
Return New NoEllipsisCell
End Get
Set(ByVal value As System.Windows.Forms.DataGridViewCell)
MyBase.CellTemplate = value
End Set
End Property
End Class
Public Class NoEllipsisCell
Inherits DataGridViewTextBoxCell
Protected Overrides Sub Paint(ByVal graphics As System.Drawing.Graphics, ByVal clipBounds As System.Drawing.Rectangle, ByVal cellBounds As System.Drawing.Rectangle, ByVal rowIndex As Integer, ByVal cellState As System.Windows.Forms.DataGridViewElementStates, ByVal value As Object, ByVal formattedValue As Object, ByVal errorText As String, ByVal cellStyle As System.Windows.Forms.DataGridViewCellStyle, ByVal advancedBorderStyle As System.Windows.Forms.DataGridViewAdvancedBorderStyle, ByVal paintParts As System.Windows.Forms.DataGridViewPaintParts)
paintParts = paintParts And Not DataGridViewPaintParts.ContentForeground
MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts)
Dim format As New StringFormat(StringFormatFlags.NoWrap)
format.LineAlignment = StringAlignment.Center
format.Trimming = StringTrimming.Word 'or Character
Dim brush As New SolidBrush(cellStyle.ForeColor)
graphics.DrawString(formattedValue, cellStyle.Font, brush, cellBounds, format)
brush.Dispose()
format.Dispose()
End Sub
End Class
Private Sub lblKnot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblKnotAA.Click, lblKnotAB.Click, lblKnotAC.Click, lblKnotAD.Click, lblKnotAE.Click, lblKnotAF.Click, lblKnotAG.Click, lblKnotAH.Click, lblKnotAI.Click, lblKnotAJ.Click, lblKnotAK.Click, lblKnotAL.Click, lblKnotAM.Click,
lblKnotBA.Click, lblKnotBB.Click, lblKnotBC.Click, lblKnotBD.Click, lblKnotBE.Click, lblKnotBF.Click, lblKnotBG.Click, lblKnotBH.Click, lblKnotBI.Click, lblKnotBJ.Click, lblKnotBK.Click, lblKnotBL.Click, lblKnotBM.Click, lblKnotCA.Click, lblKnotCB.Click, lblKnotCC.Click, lblKnotCD.Click, lblKnotCE.Click, lblKnotCF.Click, lblKnotCG.Click, lblKnotCH.Click, lblKnotCI.Click, lblKnotCJ.Click, lblKnotCK.Click, lblKnotCL.Click, lblKnotCM.Click,
lblKnotDA.Click, lblKnotDB.Click, lblKnotDC.Click, lblKnotDD.Click, lblKnotDE.Click, lblKnotDF.Click, lblKnotDG.Click, lblKnotDH.Click, lblKnotDI.Click, lblKnotDJ.Click, lblKnotDK.Click, lblKnotDL.Click, lblKnotDM.Click, lblKnotEA.Click, lblKnotEB.Click, lblKnotEC.Click, lblKnotED.Click, lblKnotEE.Click, lblKnotEF.Click, lblKnotEG.Click, lblKnotEH.Click, lblKnotEI.Click, lblKnotEJ.Click, lblKnotEK.Click, lblKnotEL.Click, lblKnotEM.Click,
lblKnotFA.Click, lblKnotFB.Click, lblKnotFC.Click, lblKnotFD.Click, lblKnotFE.Click, lblKnotFF.Click, lblKnotFG.Click, lblKnotFH.Click, lblKnotFI.Click, lblKnotFJ.Click, lblKnotFK.Click, lblKnotFL.Click, lblKnotFM.Click, lblKnotGA.Click, lblKnotGB.Click, lblKnotGC.Click, lblKnotGD.Click, lblKnotGE.Click, lblKnotGF.Click, lblKnotGG.Click, lblKnotGH.Click, lblKnotGI.Click, lblKnotGJ.Click, lblKnotGK.Click, lblKnotGL.Click, lblKnotGM.Click,
lblKnotHA.Click, lblKnotHB.Click, lblKnotHC.Click, lblKnotHD.Click, lblKnotHE.Click, lblKnotHF.Click, lblKnotHG.Click, lblKnotHH.Click, lblKnotHI.Click, lblKnotHJ.Click, lblKnotHK.Click, lblKnotHL.Click, lblKnotHM.Click, lblKnotIA.Click, lblKnotIB.Click, lblKnotIC.Click, lblKnotID.Click, lblKnotIE.Click, lblKnotIF.Click, lblKnotIG.Click, lblKnotIH.Click, lblKnotII.Click, lblKnotIJ.Click, lblKnotIK.Click, lblKnotIL.Click, lblKnotIM.Click,
lblKnotJA.Click, lblKnotJB.Click, lblKnotJC.Click, lblKnotJD.Click, lblKnotJE.Click, lblKnotJF.Click, lblKnotJG.Click, lblKnotJH.Click, lblKnotJI.Click, lblKnotJJ.Click, lblKnotJK.Click, lblKnotJL.Click, lblKnotJM.Click, lblKnotKA.Click, lblKnotKC.Click, lblKnotKD.Click, lblKnotKE.Click, lblKnotKF.Click, lblKnotKG.Click, lblKnotKH.Click, lblKnotKI.Click, lblKnotKJ.Click, lblKnotKK.Click, lblKnotKM.Click, lblKnotLA.Click, lblKnotLB.Click,
lblKnotLC.Click, lblKnotLD.Click, lblKnotLE.Click, lblKnotLF.Click, lblKnotLG.Click, lblKnotLH.Click, lblKnotLI.Click, lblKnotLJ.Click, lblKnotLK.Click, lblKnotLL.Click, lblKnotLM.Click, lblKnotMB.Click, lblKnotMC.Click, lblKnotMD.Click, lblKnotME.Click, lblKnotMF.Click, lblKnotMG.Click, lblKnotMH.Click, lblKnotMI.Click, lblKnotMJ.Click, lblKnotMK.Click, lblKnotML.Click, lblKnotNA.Click, lblKnotNC.Click, lblKnotND.Click, lblKnotNE.Click,
lblKnotNF.Click, lblKnotNG.Click, lblKnotNH.Click, lblKnotNI.Click, lblKnotNJ.Click, lblKnotNK.Click, lblKnotNM.Click, lblKnotOA.Click, lblKnotOB.Click, lblKnotOC.Click, lblKnotOD.Click, lblKnotOE.Click, lblKnotOF.Click, lblKnotOG.Click, lblKnotOH.Click, lblKnotOI.Click, lblKnotOJ.Click, lblKnotOK.Click, lblKnotOL.Click, lblKnotOM.Click, lblKnotPB.Click, lblKnotPC.Click, lblKnotPD.Click, lblKnotPE.Click, lblKnotPF.Click, lblKnotPG.Click,
lblKnotPH.Click, lblKnotPI.Click, lblKnotPJ.Click, lblKnotPK.Click, lblKnotPL.Click, lblKnotPM.Click, lblKnotQM.Click
If IsNothing(objSenderName) = False Then
objSenderName.BorderStyle = BorderStyle.None
End If
lblKnotDisp.Text = sender.Text
sender.BorderStyle = BorderStyle.FixedSingle
objSenderName = sender
End Sub
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
transparentImage = New Bitmap(30, 30)
Dim graphics As Graphics = graphics.FromImage(transparentImage)
graphics.FillRectangle(Brushes.Transparent, 0, 0, 30, 30)
graphics.Dispose()
numRows.Value = 30
numColumns.Value = 45
FillGrid()
End Sub
Public Sub FillGrid()
dgvPattern.Columns.Clear()
Dim RTotal As Integer = numRows.Value : If RTotal = 0 Then RTotal = 30
Dim CTotal As Integer = numColumns.Value : If CTotal = 0 Then CTotal = 45
For cIdx = 1 To CTotal
'dgvPattern.Columns.Add(New DataGridViewTextBoxColumn)
dgvPattern.Columns.Add(New NoEllipsisColumn)
'dgvPattern.Columns.Add(New DataGridViewImageColumn)
dgvPattern.Columns(cIdx - 1).Width = 20
Next
dgvPattern.DefaultCellStyle.WrapMode = DataGridViewTriState.False
dgvPattern.DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopRight
dgvPattern.Rows.Add(RTotal)
dgvPattern.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopRight
End Sub
Private Sub numRows_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles numRows.ValueChanged
FillGrid()
End Sub
Private Sub numColumns_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles numColumns.ValueChanged
FillGrid()
End Sub
Private Sub dgvPattern_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvPattern.CellMouseClick
'dgvPattern(e.ColumnIndex, e.RowIndex).DataGridView.DefaultCellStyle.Padding = New Padding(0, 0, 0, 0)
dgvPattern(e.ColumnIndex, e.RowIndex).Value = lblKnotDisp.Text
Debug.Print(dgvPattern(e.ColumnIndex, e.RowIndex).DataGridView.DefaultCellStyle.Padding.Top.ToString)
Debug.Print(dgvPattern(e.ColumnIndex, e.RowIndex).DataGridView.DefaultCellStyle.Padding.Bottom.ToString)
Debug.Print(dgvPattern(e.ColumnIndex, e.RowIndex).DataGridView.DefaultCellStyle.Padding.Left.ToString)
Debug.Print(dgvPattern(e.ColumnIndex, e.RowIndex).DataGridView.DefaultCellStyle.Padding.Right.ToString)
End Sub
End Class