Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Row From Modal Form

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
VB.Net 2003. I have a DataGrid (grdPro1) on one form. I am passing a row of the grid to a modal form using a property in the modal form. When I make a change to the row in the modal form, they do not show up in grdPro1 after returning from the modal form. I have looked at the values in the PopupWorkRow after the DialogResult.OK and they are changed. As a test I added the "HELP ME" line if I cancel out of the modal form. This change shows up immediately. Not sure why the DialogResult.OK branch isn't working. There must be something really simple I'm missing here. I've tried begin and end edit on the row and also refreshing the grid. I've used properties on modal forms many times to retrieve specific values with no problems, but never a row like this. Is it because I'm calling this code from the grdPro1.MouseDown event and looking for a right click? As you can see, I need some help here.
Code:
...
Dim Row1 As Integer
Row1 = myHitTest.Row
Dim PopupWorkRow As DataRow
PopupWorkRow = dsProFile.Tables("ProFile").Rows(Row1)
Dim ChangeColumnForm As New ChangeColumnValue
ChangeColumnForm.ProRow = PopupWorkRow
If ChangeColumnForm.ShowDialog() = DialogResult.OK Then
  PopupWorkRow = ChangeColumnForm.ProRow
Else 
  PopupWorkRow("ExceptCode") = "HELP ME"
End If

ChangeColumnForm.Close()
ChangeColumnForm.Dispose()
ChangeColumnForm= Nothing



Auguy
Sylvania/Toledo Ohio
 
Try changing your code to this and see what happens:

Code:
...
Dim Row1 As Integer
Row1 = myHitTest.Row
Dim ChangeColumnForm As New ChangeColumnValue
ChangeColumnForm.ProRow = dsProFile.Tables("ProFile").Rows(Row1)
If ChangeColumnForm.ShowDialog() = DialogResult.OK Then
  'maybe throw in a grid refresh here
Else
  PopupWorkRow("ExceptCode") = "HELP ME"
End If

ChangeColumnForm.Close()
ChangeColumnForm.Dispose()
ChangeColumnForm= Nothing

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Thanks, I'm still a little confused. It seems if I pass an integer or text to a property on the modal form and change the values in the modal form, the original value in the calling form does not change unless I explicity set it using something like variable = ModalForm.Prop1. But the row paseed seems to change as in the code you suggested without having to explicitly set it. What if I don't want the changes in the row

Auguy
Sylvania/Toledo Ohio
 

dsProFile.Tables("ProFile").Rows(Row1)[red].RejectChanges()[/red]

This undoes all changes to the DataRow since the last AcceptChanges call. This method is also available for DataTable and DataSet.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Thanks again. I think I see the light at the end of the tunnel, just hope it's not a train coming at me. And I have marked my calendar for Talk Like a Pirate Day!

Auguy
Sylvania/Toledo Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top