2012-03-28 12 views
1

Windowsフォーム、VB。私はこれと正しいサイコロに対する答えをウェブで検索しました。彼らは私が達成しようとしているものに欠けているか、CSHARPにいるので、彼らが何をしているのかを見るのが難しくなっています。私は、メインのフォームからモーダルダイアログロードイベントにレコードIDを渡す必要があります。私はparamを投げてみましたが、LoadイベントのパラメータとVBフラグを変更する必要があります..私はしようとしています整数である_CurrentPropの値をダイアログに渡します。これはWindowsフォームからモーダルへの変数の受け渡し

Private Sub PropertySettingsMenuClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PropertyDetailsToolStripMenuItem.Click 
Dim _propertSettings As New PropertySettingsWindow() 
_propertSettings.ShowDialog() 
End Sub 


Private Sub PropertySettings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
Dim _properties As New List(Of property_info) 
_properties = db.property_info.ToList 
    For Each a In _properties 
     If Not p_settingsCityList.Items.Contains(a.city) Then 
      p_settingsCityList.Items.Add(a.city) 
     End If 
    Next 

    For Each b In _properties 
     If Not p_settingsPropertyList.Items.Contains(b.property_Name) Then 
      p_settingsPropertyList.Items.Add(Convert.ToString(b.idProperties) + " -- " + b.property_Name) 
     End If 
    Next 
    p_settingsZipCode.ReadOnly = True 
    p_settings_Address.ReadOnly = True 
    p_settings_PropertyName.ReadOnly = True 

End Sub 

は、私は単にPropertySettingsクラス内のグローバル変数に値を代入するつもりですが、私はしてみてくださいすべてが何らかの形で失敗しているようだ。..ダイアログコンストラクタとそのダイアログ内のLoadイベントです。 ...任意のアイデア...

答えて

4

は、あなたは、単に

とレコードIDにアクセスすることができますし、ダイアログ形式では、この

Dim _propertSettings As New PropertySettingsWindow() 
_propertSettings.RecordID = 15 
_propertSettings.ShowDialog() 

のようなダイアログを開き、あなたのダイアログウィンドウにパブリックプロパティRecordIDを追加します。 .NET Frameworkの4.0以降

_properties = db.property_info_by_id(RecordID).ToList 

、あなたは

Private _recordID As Integer 
Property RecordID As Integer 
    Get 
     Return _recordID 
    End Get 
    Set(ByVal value As Integer) 
     _recordID = value 
    End Set 
End Property 
+2

+1を書いたり、確認する必要があります、自動実装プロパティ以前のバージョンとの

Public Property RecordID As Integer 

を使用することができ、それプライマリプロパティを設定するためのFormのコンストラクタのパラメータ - どちらも同じように有効です。 – Bridge

+0

ありがとう、私は最後のvb.net mvc3プロジェクトで大量のものを使っていることを忘れていました。 – Skindeep2366

+0

はい、フォームは単にクラスであり、クラスで何でもできることは... –

関連する問題