Where would I find the GridLineDataGridView component?

Posted on 2008-06-24
Last Modified: 2013-11-26
ipaulino has just answered a previous question about my datagridview but using a GridLineDataGridView component.

I just can't find this on the Visual Studio toolbox anywhere. Could somebody point me in the right direction please??


Question by:jerute
LVL 48

Accepted Solution

jpaulino earned 250 total points
ID: 21856625
Hi again!

Add the code on the snippet to a new class (clean all code from the new class and paste the code snippet). Then build your project.

The component will be available on the top of the toolbox.
Class GridLineDataGridView

	Inherits DataGridView


	Protected Overloads Overrides Sub OnPaint(ByVal e As PaintEventArgs)



		Dim rowHeight As Integer = Me.RowTemplate.Height

		Dim h As Integer = Me.ColumnHeadersHeight + rowHeight * Me.RowCount

		Dim imgWidth As Integer = Me.Width - 2

		Dim rFrame As New Rectangle(0, 0, imgWidth, rowHeight)

		Dim rFill As New Rectangle(1, 1, imgWidth - 2, rowHeight)

		Dim rowHeader As New Rectangle(2, 2, Me.RowHeadersWidth - 3, rowHeight)


		Dim pen As New Pen(Me.GridColor, 1)

		Dim rowImg As New Bitmap(imgWidth, rowHeight)

		Dim g As Graphics = Graphics.FromImage(rowImg)

		g.DrawRectangle(pen, rFrame)

		g.FillRectangle(New SolidBrush(Me.DefaultCellStyle.BackColor), rFill)

		g.FillRectangle(New SolidBrush(Me.RowHeadersDefaultCellStyle.BackColor), rowHeader)


		Dim rowImgAAlternative As Bitmap = TryCast(rowImg.Clone(), Bitmap)

		Dim g2 As Graphics = Graphics.FromImage(rowImgAAlternative)

		rFill.X += Me.RowHeadersWidth - 1

		g2.FillRectangle(New SolidBrush(Me.AlternatingRowsDefaultCellStyle.BackColor), rFill)


		Dim w As Integer = Me.RowHeadersWidth - 1

		For j As Integer = 0 To Me.ColumnCount - 1

			g.DrawLine(pen, New Point(w, 0), New Point(w, rowHeight))

			g2.DrawLine(pen, New Point(w, 0), New Point(w, rowHeight))

			w += Me.Columns(j).Width



		Dim [loop] As Integer = (Me.Height - h) / rowHeight

		For j As Integer = 0 To [loop]

			Dim index As Integer = Me.RowCount + j

			If index Mod 2 = 0 Then

				e.Graphics.DrawImage(rowImg, 1, h + j * rowHeight)


				e.Graphics.DrawImage(rowImgAAlternative, 1, h + j * rowHeight)

			End If



	End Sub


End Class

Open in new window


Author Comment

ID: 21856795


Thanks again. LOL.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
More and more people are using the enhanced small form-factor pluggable (SFP+) tranceivers, and speed is of utmost importance. Testing of speeds are critical to ensure that the devices will meet the speed requirements. There are some testing challen…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now