Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

GridView and line type

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
R.A.F. - 24 Oct 2007 19:52 GMT
Hi,

I would like to paint the gridline of my DataGridView not as solid, but
as Dash line for example.

I did not see any property to do that, therefore how can i perform this
task ?

thanks a lot,

RAF
Nicholas Paldino [.NET/C# MVP] - 24 Oct 2007 20:37 GMT
RAF,

   You can't, at least without custom painting.  If you want to draw a
dashed line, you will have to set the border style of the grid to None, and
then draw the dashed lines in the space where the border would be.
Fortunately, it does not look like the grid changes its size when you change
the border style, so the space where the border would be should be empty
when you set the border style to none.

   To draw the dashes, you will want to create a Pen to use with the
DrawRectangle method on the Graphics instance passed to your event handler
(or OnPaint method).  On that Pen instance, you would change the DashStyle
property to one of the values in the DashStyle enumeration, most likely
DashStyle.Dash or DashStyle.Dot.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi,
>
[quoted text clipped - 7 lines]
>
> RAF
R.A.F. - 25 Oct 2007 10:15 GMT
But Custom painting means in this case to redraw the whole control :-(

> RAF,
>
[quoted text clipped - 10 lines]
> property to one of the values in the DashStyle enumeration, most likely
> DashStyle.Dash or DashStyle.Dot.
Nicholas Paldino [.NET/C# MVP] - 25 Oct 2007 15:36 GMT
No, not really.  You can call the base implementation, and then draw
OVER that.  Since you are just drawing a border, you shouldn't have a
problem.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> But Custom painting means in this case to redraw the whole control :-(
>
[quoted text clipped - 12 lines]
>> DashStyle property to one of the values in the DashStyle enumeration,
>> most likely DashStyle.Dash or DashStyle.Dot.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.