Android Публикувано Март 17, 2011 Report Share Публикувано Март 17, 2011 Здравейте! Тук съм за да попитам нещо, което ми привлече вниманието, но не можах да го направя, та... Въпроса ми е следния, как да направя така, че при натискане на хикса за изход от програмата да те пита дали си съгласен да я напуснеш с "Yes/No" question? Ако на някой му се занимава, нека ми опише малко по-подробно как да постигна този ефект, благодаря. Цитирай Link to comment Сподели другаде More sharing options...
panevdd Публикувано Март 17, 2011 Report Share Публикувано Март 17, 2011 Потърси информация за visual basic confirmation on exit, аз намерих това и това. Цитирай Link to comment Сподели другаде More sharing options...
Android Публикувано Март 18, 2011 Author Report Share Публикувано Март 18, 2011 Public Class Form1 Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If e.CloseReason = CloseReason.UserClosing Then Dim NeedsSave As Boolean = False 'Perform contextual validations here and (re)set NeedsSave accordingly... NeedsSave = True '<-- Testing value. If NeedsSave Then Dim result As DialogResult = MessageBox.Show("You have some unsaved changes. " _ & "Do you want to save them now?", "Unsaved Changes", MessageBoxButtons.YesNoCancel, _ MessageBoxIcon.Information) Select Case result Case Windows.Forms.DialogResult.Cancel 'Cancel the form closing. e.Cancel = True Return Case Windows.Forms.DialogResult.Yes If SaveChanges() = False Then 'The user should still be able to cancel out here so 'that hanges are not lost (as long as the user can 'perform the changes. If MessageBox.Show("The save failed. Do you still want close?", _ "Save Failed", MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.Cancel Then e.Cancel = True Return Else 'Allow the form to close. End If End If Case Else 'Allow the form to close. End Select End If End If End Sub Private Function SaveChanges() As Boolean 'Place save algorithm here... 'True = success, False means the save failed. Return False '<--For testing. End Function End Class Ето на някой ако му трябва в случай, че има желание да си го направи да го пита дали иска да се запазват промените преди изход от програмата. Цитирай Link to comment Сподели другаде More sharing options...
snikcho Публикувано Октомври 14, 2011 Report Share Публикувано Октомври 14, 2011 Мерси и на мен ми помогна. Цитирай Link to comment Сподели другаде More sharing options...
Препоръчан пост
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.