Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

DataGridView: How to place button in leftmost column's header cell?

Posted on 2006-07-01
1
Medium Priority
?
385 Views
Last Modified: 2008-01-16
Hello,

I have a DataGridView and I would like to place a button in the leftmost column's header cell.  This button will be clicked by a user to insert a new record in the DGV rather than using the DGV's usual features.  Each row, has  "Delete" and "Edit" buttons, which work perfectly.  Anyway, I have scoured the forums and Googled, but have only found the following reference that provides some information about programming this idea:

 http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=134933&SiteID=1

Unfortunately, it didn't work.  The instructions said to subclass the DGV, override the OnMouseClick method, and look for when the "Row and Column index values are -1".  There is only one parameter to the method and it does not contain these fields...  The closest matches are X and Y and Location.X and Location.Y, and these fields never contained -1 when I clicked the header cell...  It seems to me that others must have accomplished placing a button in this location... HELP!!!  Currently, I have placed an "Insert" button on the form, but it would be much more meaningful in the location that I have mentioned...  Closer to the context of the operation to be performed on the DGV.

Thanks in advance for any and all ideas!

Mike
0
Comment
Question by:mjgardne
[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
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 750 total points
ID: 17026074
Here is the culprit:

Private Sub OnTopLeftHeaderMouseDown()
      If Me.MultiSelect Then
            Me.SelectAll
            If (-1 <> Me.ptCurrentCell.X) Then
                  Me.SetCurrentCellAddressCore(Me.ptCurrentCell.X, Me.ptCurrentCell.Y, False, False, False)
            End If
      End If
End Sub

One possibility would be to place a control, like a Button over that region, so that a mouse click can't occur in that cell.

Bob
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

647 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