Click here to Skip to main content
15,898,134 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Disabling combobox items... Pin
Tom John9-Nov-04 7:36
Tom John9-Nov-04 7:36 
GeneralVery simple question Pin
Boniolopez8-Nov-04 12:15
Boniolopez8-Nov-04 12:15 
GeneralRe: Very simple question Pin
beowulfagate8-Nov-04 13:17
beowulfagate8-Nov-04 13:17 
GeneralRe: Very simple question Pin
axiomillies14-Nov-04 19:16
axiomillies14-Nov-04 19:16 
GeneralConvert Sprite Sheets to Animations Pin
maykut20998-Nov-04 12:05
maykut20998-Nov-04 12:05 
GeneralForm.ShowDialog() problem Pin
genosis8-Nov-04 7:39
genosis8-Nov-04 7:39 
GeneralRe: Form.ShowDialog() problem Pin
CodeWell17-Nov-04 20:56
CodeWell17-Nov-04 20:56 
GeneralRe: Form.ShowDialog() problem Pin
genosis18-Nov-04 5:07
genosis18-Nov-04 5:07 
Thanks fot the reply. I am rewriting all the forms and this time I am not using Windows Designer.

At the begining one of my friends warned me not to us VS.NET's designer generated code and I did not listen to him Frown | :( Up to this point VS.NET caused a lot of problems from corrupting hard-coded Turkish characters to this problem.

But I still would like to learn the cause of the problem. I will send you the code.

Imports System.Configuration

Public Class VillageEdit
Inherits System.Windows.Forms.Form

Private useCode As Boolean = True

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TxtVillageCode As MandraApplication.MTextBox
Friend WithEvents TxtVillageName As MandraApplication.MTextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Utilities.WriteLog("VillageEdit.InitializeComponent entered")
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(VillageEdit))
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.TxtVillageCode = New MandraApplication.MTextBox()
Me.TxtVillageName = New MandraApplication.MTextBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 16)
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 0
Me.Label1.Text = "Köy Kodu:"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 51)
Me.Label2.Name = "Label2"
Me.Label2.TabIndex = 0
Me.Label2.Text = "Köy Adı:"
'
'TxtVillageCode
'
Me.TxtVillageCode.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TxtVillageCode.Location = New System.Drawing.Point(120, 16)
Me.TxtVillageCode.MaxLength = 2
Me.TxtVillageCode.Name = "TxtVillageCode"
Me.TxtVillageCode.Size = New System.Drawing.Size(48, 22)
Me.TxtVillageCode.TabIndex = 0
Me.TxtVillageCode.Text = ""
'
'TxtVillageName
'
Me.TxtVillageName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TxtVillageName.Location = New System.Drawing.Point(120, 48)
Me.TxtVillageName.MaxLength = 35
Me.TxtVillageName.Name = "TxtVillageName"
Me.TxtVillageName.Size = New System.Drawing.Size(160, 22)
Me.TxtVillageName.TabIndex = 1
Me.TxtVillageName.Text = ""
'
'Button1
'
Me.Button1.Image = CType(resources.GetObject("Button1.Image"), System.Drawing.Bitmap)
Me.Button1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight
Me.Button1.Location = New System.Drawing.Point(8, 96)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(128, 32)
Me.Button1.TabIndex = 2
Me.Button1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'Button2
'
Me.Button2.Image = CType(resources.GetObject("Button2.Image"), System.Drawing.Bitmap)
Me.Button2.ImageAlign = System.Drawing.ContentAlignment.MiddleRight
Me.Button2.Location = New System.Drawing.Point(152, 96)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(128, 32)
Me.Button2.TabIndex = 3
Me.Button2.Text = "Çıkış [Esc] "
Me.Button2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'VillageEdit
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
Me.ClientSize = New System.Drawing.Size(292, 142)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Button1, Me.TxtVillageCode, Me.Label1, Me.Label2, Me.TxtVillageName})
Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(162, Byte))
Me.Name = "VillageEdit"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "VillageEdit"
Me.ResumeLayout(False)
Utilities.WriteLog("VillageEdit.InitializeComponent exited")
End Sub

#End Region

Public Sub New(ByVal v As Village)
Me.New()
Village = v
End Sub

Public Village As Village
Private AutoCodeAssignment As Boolean = False

Private Sub VillageEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Utilities.WriteLog("VillageEdit.VillageEdit_Load entered")
Me.KeyPreview = True
Me.DialogResult = DialogResult.Cancel

AutoCodeAssignment = Boolean.Parse(ConfigurationSettings.AppSettings("autoCodeAssignment"))

If AutoCodeAssignment Then
TxtVillageCode.Enabled = False
End If

If Village Is Nothing Then
Button1.Text = "Ekle [F5]"
Me.Text = "Yeni Köy Ekle"

'Auto generate a village code
If AutoCodeAssignment Then
Dim vf As New VillageFactory(Utilities.Conn)
Dim vc As VillageCollection = vf.RetrieveAll(False)
Dim index As Integer
Dim v As Village

Dim IndexFound As Boolean
For index = 1 To 100
IndexFound = False
For Each v In vc
If index = Convert.ToInt32(v.Code) Then
IndexFound = True
Exit For
End If
Next
If Not IndexFound Then
TxtVillageCode.Text = index.ToString("0#")
Exit For
End If
Next
End If

Else
Button1.Text = "Güncelle [F5]"
Me.Text = "Köy Güncelle"
TxtVillageCode.Text = Village.Code
TxtVillageName.Text = Village.Name
End If
AddHandler TxtVillageCode.KeyUp, AddressOf Control_KeyUp
AddHandler TxtVillageName.KeyUp, AddressOf Control_KeyUp
AddHandler Button1.KeyUp, AddressOf Control_KeyUp
Utilities.WriteLog("VillageEdit.VillageEdit_Load exited")
Catch ex As System.Exception
MaintainanceDevice.ReportException(ex)
End Try
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
'Check Entered village code
If Not Utilities.CheckVillageCodeFormat(TxtVillageCode.Text) Then
MessageBox.Show("Geçersiz köy kodu", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error)
TxtVillageCode.Focus()
TxtVillageCode.SelectAll()
Exit Sub
End If

If TxtVillageName.Text.Length < 3 Then
MessageBox.Show("Geçersiz köy adı. Köy adı en az 3 en karakterli olabilir.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error)
TxtVillageName.Focus()
Exit Sub
End If

Dim Vt As Village
Dim vf As New VillageFactory(Utilities.Conn)

If Village Is Nothing Then
Vt = vf.GetVillage(TxtVillageCode.Text, False)
If Not Vt Is Nothing Then
MessageBox.Show("Sistemde " & Vt.Code & " kodlu bir köy (" & Vt.Name & ") bulunmakta.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error)
TxtVillageCode.Focus()
TxtVillageCode.SelectAll()
Exit Sub
End If
Vt = Nothing
Vt = vf.GetVillageByName(TxtVillageName.Text, False)
If Not Vt Is Nothing Then
MessageBox.Show("Bu isimde bir köy sistemde tanımlı", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error)
TxtVillageName.Focus()
TxtVillageName.SelectAll()
Exit Sub
End If
Village = New Village(0, TxtVillageCode.Text, TxtVillageName.Text)
Village = vf.SaveVillage(Village)
Else
Vt = vf.GetVillage(TxtVillageCode.Text, False)
If Not Vt Is Nothing And Vt.ID <> Village.ID Then
MessageBox.Show("Sistemde " & Vt.Code & " kodlu bir köy (" & Vt.Name & ") bulunmakta.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error)
TxtVillageCode.Focus()
TxtVillageCode.SelectAll()
Exit Sub
End If

Vt = vf.GetVillageByName(TxtVillageName.Text, False)
If Not Vt Is Nothing AndAlso Vt.Code <> Village.Code Then
MessageBox.Show("Bu isimde bir köy sistemde tanımlı", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Village = vf.SaveVillage(New Village(Village.ID, TxtVillageCode.Text, TxtVillageName.Text))

End If
Me.DialogResult = DialogResult.OK
Me.Close()
Catch ex As System.Exception
MaintainanceDevice.ReportException(ex)
End Try
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
''Me.Close()
End Sub

Private Sub VillageEdit_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
Select Case e.KeyData
Case Keys.F5
Button1.PerformClick()
End Select
End Sub

Private Sub Control_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
Try
If sender Is TxtVillageCode Then
If e.KeyData = Keys.Enter Then
TxtVillageName.Focus()
End If
ElseIf sender Is TxtVillageName Then
If e.KeyData = Keys.Enter Then
Button1.Focus()
ElseIf e.KeyData = Keys.Back Then
If TxtVillageName.Text.Length = 0 Then
If Not AutoCodeAssignment Then
TxtVillageCode.Focus()
End If
End If
End If
ElseIf sender Is Button1 Then
If e.KeyData = Keys.Back Then
TxtVillageName.Focus()
End If
End If
Catch ex As System.Exception
MaintainanceDevice.ReportException(ex)
End Try
End Sub
End Class
GeneralRe: Form.ShowDialog() problem Pin
CodeWell18-Nov-04 13:17
CodeWell18-Nov-04 13:17 
GeneralVB.NET from XP SP2 to Win2k Pin
StrayGrey8-Nov-04 6:35
StrayGrey8-Nov-04 6:35 
GeneralUrgent Help Needed Vb.Net ReportViewer Pin
partt8-Nov-04 6:09
partt8-Nov-04 6:09 
GeneralJoin Team FreeSoft. Join the team! Pin
Mickiecp8-Nov-04 5:58
Mickiecp8-Nov-04 5:58 
GeneralPDF Woes....Please Help Pin
Mark the Shark8-Nov-04 4:48
Mark the Shark8-Nov-04 4:48 
GeneralRe: PDF Woes....Please Help Pin
CodeWell21-Nov-04 15:02
CodeWell21-Nov-04 15:02 
GeneralRe: PDF Woes....Please Help Pin
Mark the Shark22-Nov-04 1:40
Mark the Shark22-Nov-04 1:40 
GeneralVB.NET, Framesets, refreshing a frame from another frame. Pin
Jerry Walter8-Nov-04 3:51
Jerry Walter8-Nov-04 3:51 
GeneralRe: VB.NET, Framesets, refreshing a frame from another frame. Pin
Dave Kreskowiak8-Nov-04 8:07
mveDave Kreskowiak8-Nov-04 8:07 
Generaldropdown in listview Pin
liddicott8-Nov-04 3:26
liddicott8-Nov-04 3:26 
GeneralRe: dropdown in listview Pin
Tom John9-Nov-04 2:52
Tom John9-Nov-04 2:52 
QuestionSending emails using VB.Net ? Pin
Modern_night8-Nov-04 2:07
Modern_night8-Nov-04 2:07 
AnswerRe: Sending emails using VB.Net ? Pin
Purple Monk8-Nov-04 2:38
Purple Monk8-Nov-04 2:38 
GeneralRe: Sending emails using VB.Net ? Pin
Modern_night8-Nov-04 7:23
Modern_night8-Nov-04 7:23 
GeneralRe: Sending emails using VB.Net ? Pin
Modern_night10-Nov-04 14:18
Modern_night10-Nov-04 14:18 
GeneralOpen My Documents Pin
kellydanielc8-Nov-04 0:29
kellydanielc8-Nov-04 0:29 
GeneralRe: Open My Documents Pin
Purple Monk8-Nov-04 1:48
Purple Monk8-Nov-04 1:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.