Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Where would I find the GridLineDataGridView component?

Posted on 2008-06-24
2
Medium Priority
?
277 Views
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??

Regards


Frustrated.
0
Comment
Question by:jerute
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 1000 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)
		MyBase.OnPaint(e)
 
		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
		Next
 
		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)
			Else
				e.Graphics.DrawImage(rowImgAAlternative, 1, h + j * rowHeight)
			End If
		Next
 
	End Sub
 
End Class

Open in new window

0
 

Author Comment

by:jerute
ID: 21856795
A-HA!!!

:-)

Thanks again. LOL.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In the modern office, employees tend to move around the workplace a lot more freely. Conferences, collaborative groups, flexible seating and working from home require a new level of mobility. Technology has not only changed the behavior and the expe…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

722 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