How to detect changes to a bound data - vb.net

Winforms App - VB.Net 4.6.1
I have a data table that I fill when my form loads as follows:
Private Sub OnFormLoad(sender As Object, e As EventArgs) Handles MyBase.Load
Me.ApGetMratesListTableAdapter.Fill(Me.DsMRatesList.apGetMratesList)
End Sub
On the form I have textbox bound (Me.ApGetMratesListBindingSource) to a field in this datatable . I want to catch some sort of "RowChanged" event when the value in the textbox changes so I can set a "dirty" flag. Unfortunately after an hour of Googling and reading page after page with no examples of how to write the method I'm asking for help. Basically I cannot figure out how to refer to the event i.e. the part after HANDLES.
Private Sub SetDirty(ByVal sender As System.Object,
ByVal e As DataRowChangeEventArgs) Handles ?
m_IsDirty = True
End Sub
I've experimented until I ran out of options. If anyone can clue me as to how to write the event for the above Sub I'd be very grateful. If the signature isn't correct please clue me on that as well. Thank you!

Related

vb.net masked textbox and datetime now string not working together?

I have a masked textbox set to date.short I would like to automate the cuurentdate to be filled in when the masked textbox is clicked I though the following would work but I get the error InvalidCastExpectation was ungandeld "Application is in break mode"
Private Sub MaskedTextBox1_Click(sender As Object, e As MaskInputRejectedEventArgs) Handles MaskedTextBox1.Click
MaskedTextBox1.Text = DateTime.Now.ToString("dd/MM/yyyy")
End Sub
I also thought about changing ("dd/MM/yyyy") to ("dd-MM-yyyy") but this also dosnt fix it?
The Click event does not use the MaskInputRejectedEventArgs parameter:
Private Sub MaskedTextBox1_Click(sender As Object, e As EventArgs)
Handles MaskedTextBox1.Click

Allow form to be edited once user clicks edit button

I'm coding in Visual Basic. I have a file in Access that I am using as my Data Source. I have the form I am creating that is completely Read Only, so the user will not be able to edit any of the information.
My question is, I have created a button also on the form that I would like to put the form into edit mode when the user clicks the button, so the user will be able to make changes.
How would i go about doing that?
I'm not sure if this level of simplicity is what you're looking for or not...
Private Sub Form1_Load(sender As System.Object, e As EventArgs) Handles Me.Load
GroupBox1.Enable = False
End Sub
Private Sub btnEdit_Click(sender As Object, e As EventArgs) Handles btnEdit.Click
GroupBox1.Enable = True
End Sub
I highly recommend you read this thought for the future:
https://stackoverflow.com/help/how-to-ask
I'd also recommend watching tutorial videos and reading MSDN documentation on VB.NET.

Refresh dgv works only with the activated event, why?

I have two forms both with a dgv connected to two different datasets. When i change my data in one of the datasets i have to refresh the other one (i know the solution is not the best). After trying many many different ways of rebinding, refreshing and so i found the following code working:
Private Sub View_Activated(byval sender as Object, _ Byval e as
System.Eventargs) Handels MyBase.Activated Table_Load(Nothing,
Nothing) End Sub
Private Sub View_Load(byval sender as Object, _ byval e as
system.eventargs) Handels Mybase.Load
Me.TableAdapter.Fill(Me.Dataset.Table) End Sub
After Chaning things in dgv1 i can see the changes in dgv2 with these commands. BUT when i change mybase.activated to mybase.shown or something else it is not working anymore. Apparently this only works when i use the event activated, but i have no idea why?
BTW. I totally dont understand why the dgv is updated with the new data when i have my activated-event but when i comment the activated-event out the dgv is not updated.
The form's Activated event fires when the form window gets focus. The Load event only fires when the form is initially loaded.
When you make a change on one form, and change focus to the second form, Activated fires.

Windows form closing automatically when parent window gets focus

VB Windows form Application.. I am developing an application of which part of the program is around configuration settings allowing the user to enter configuration items. When the menubar item for configuration menu is clicked on the main form the menu opens. This is fine but the mainform should not become active again until the configuration menu has closed. This does not happen right now and the mainform simply comes to the foreground and the configuration form goes to the background... I realize that coding an event on the Child form to handle this would not work because the child window loses control and the main form gains control.. I thought of coding a function as follows on the main form but it does not seem logical because i would have to add to it for everyform and do checking to make sure the child is actually open before trying to close it..
Private Sub Form1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus
MailSettingsWindow.Close()
RentalSettingsWindow.Close()
End Sub
I did away with the above sub routine and used the below code as per the recomendation of using showdialog which works just as i was looking for.
Private Sub MailingAndEmailSettingsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MailingAndEmailSettingsToolStripMenuItem.Click
Dim MailConfig As New MailSettingsWindow()
MailSettingsWindow.Showdialog()
End Sub
I did away with the above sub routine and used the below code as per the recommendation of using ShowDialog which works just as I was looking for.
My code is as follows:
Private Sub MailingAndEmailSettingsMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles MailingAndEmailSettingsMenuItem.Click
Dim MailConfig As New MailSettingsWindow()
MailSettingsWindow.ShowDialog()
End Sub

vb.net winform 2008 datagrid doubleclick event not firing

i have a databound datagrid in vb.net 2008. This is a program where i use the double click event multipal times.. but for some reason on a new form it's not working anymore. In code behind i selected the datagrid and double click event. when i double click on teh grid in debug mode, it never fires off the event(i put a breakpoint in). I've tried several other events and none of them are firing.
Here is what the event look like
Private Sub dgWho2_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgWho2.DoubleClick
End Sub
and here is what it looks like for one that is working on another form
Private Sub dgQueryStats_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgQueryStats.DoubleClick
For Each O As asr.QueryStat In Os
If O.RowID = CInt(Me.dgQueryStats.Tag.ToString) Then
Me.lblQuery.Text = O.Text
End If
Next
Me.cmdCopyQuery.Visible = True
End Sub
in comparing the properties of the two datagrid, other than the name and the binding, they look the same as well. wondering if anyone has an idea.
thanks
shannon
Err... found my problem.. i had a datagrid.enabled=false stuck down in some code...
Sorry about that
shannon