Passing a value from one form to a datagrid on another form

Hi,
I have a form with a datagrid and when the datagrid is Mouse down event I capture the Hit Info in a class.  I also open a form that has a calander on it.  I want to take the selected date and put it in the cell they click on.  But when I try to place the value from frmCalander into the form that has the datagrid I get a error saying that the data grid must be bound to a datatable.  Here is my code.

main form
Dim grdActionItem_RevisitDate As DataGrid = CType(sender, DataGrid)
        Dim HitTestInfo As System.Windows.Forms.DataGrid.HitTestInfo
        HitTestInfo = grdActionItem_RevisitDate.HitTest(e.X, e.Y)
       
        If System.Windows.Forms.DataGrid.HitTestType.Cell And HitTestInfo.Column = 1 Then
            Dim frmCalander As New frmCalander
            GridHitTestInfo.ActionItemHitTestInfo = HitTestInfo 'This is a class I created to capture the hit info
            frmCalander.TopMost = True
            frmCalander.Show()
            frmCalander.WindowState = FormWindowState.Normal
       End If




frmCalander******************
Private Sub Calander_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles Calander.DateSelected
        Dim frmMain As New frmMain
        frmMain.ActionItemDate.ActionItemDate = e.Start
        frmMain.dgrdActionItem.DataSource = frmMain.DsActionItem1
     
frmMain.dgrdActionItem.Item(frmMain.GridHitTestInfo.ActionItemHitTestInfo.Row,     frmMain.GridHitTestInfo.ActionItemHitTestInfo.Column) = e.Start
        Me.Close()
    End Sub

im not sure how else to go about this any help would be killer
Thanks JW
justinwood88Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

karthikeyanTPCommented:
Hai,

If your primary goal is to have a DateTimePicker (a calendar from which a user can select a date), you might probably look at the following link which addresses the issue of adding a datetimepicker in a datagrid.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatagridcolumnstyleclasstopic.asp

Good luck
0
justinwood88Author Commented:
That is my primary goal but unfortunately, I have today to solve this problem and implement it through out my project.  This web sit is exactly what I will do in the future but time restraints have caused me to find a quick fix.  I’m trying to pass a value from a second form to the first's forms datagrid.

JW
0
justinwood88Author Commented:
I Figured It out!!!!!
This is what I was missing.
I forgot to set the frmCalanders frmMain Object to the instance of it self on frmMain. I think I said that right.

Public Class frmCalander
    Inherits System.Windows.Forms.Form
    Public objForm As Object

       Private Sub Calander_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles Calander.DateSelected


        frmMain.ActionItemDate.ActionItemDate = e.Start
        CType(objForm, frmMain).dgrdActionItem.Item(frmMain.GridHitTestInfo.ActionItemHitTestInfo.Row, frmMain.GridHitTestInfo.ActionItemHitTestInfo.Column) = e.Start
        'frmMain.dgrdActionItem.Item(frmMain.GridHitTestInfo.ActionItemHitTestInfo.Row, frmMain.GridHitTestInfo.ActionItemHitTestInfo.Column) = e.Start

        Me.Close()
    End Sub
End Class

Private Sub dgrdActionItem_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgrdActionItem.MouseDown
        Dim grdActionItem_RevisitDate As DataGrid = CType(sender, DataGrid)
        Dim HitTestInfo As System.Windows.Forms.DataGrid.HitTestInfo
        HitTestInfo = grdActionItem_RevisitDate.HitTest(e.X, e.Y)
       
        If System.Windows.Forms.DataGrid.HitTestType.Cell And HitTestInfo.Column = 1 Then
            Dim frmCalander As New frmCalander
            MsgBox(HitTestInfo.Column)
            GridHitTestInfo.ActionItemHitTestInfo = HitTestInfo

**************Here is the Line I was Missing********************************
            frmCalander.objForm = Me
********************************************************************
            frmCalander.TopMost = True
            frmCalander.Show()
            frmCalander.WindowState = FormWindowState.Normal
            'grdActionItem_RevisitDate.Item(HitTestInfo.Row, HitTestInfo.Column) = ActionItemDate.ActionItemDate
        End If
    End Sub

Thanks karthikeyanTP  for that link I will use it in the future for more than just the datapicker.  I am assuming that it will work for combo boxs and other controls alike

Thanks

JW
0
moduloCommented:
PAQed with points refunded (250)

modulo
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.