01-12-13, 12:05 AM
PHP كود :
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Namespace WindowsFormsApplication1
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub dataGridView1_SelectionChanged(sender As Object, e As EventArgs)
If dataGridView1.SelectedRows.Count > 0 Then
label1.Text = dataGridView1.SelectedRows(0).Index.ToString()
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs)
Dim c As New [MyClass]()
dataGridView1.DataSource = c.GetData()
Column1.DataSource = c.GetData()
Column1.DisplayMember = "Name"
Column1.ValueMember = "Salary"
End Sub
Private Sub dataGridView1_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs)
If dataGridView1.SelectedRows(0).Cells(0).ColumnIndex = 0 Then
Dim cb As ComboBox = TryCast(e.Control, ComboBox)
If cb IsNot Nothing Then
RemoveHandler cb.SelectionChangeCommitted, New EventHandler(AddressOf cb_SelectedIndexChanged)
AddHandler cb.SelectionChangeCommitted, New EventHandler(AddressOf cb_SelectedIndexChanged)
End If
End If
End Sub
Private Sub cb_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim cb As ComboBox = TryCast(sender, ComboBox)
If cb.SelectedValue IsNot Nothing Then
MessageBox.Show(cb.SelectedValue.ToString())
End If
End Sub
End Class
Class [MyClass]
Public Property Name() As String
Get
Return m_Name
End Get
Set
m_Name = Value
End Set
End Property
Private m_Name As String
Public Property Address() As String
Get
Return m_Address
End Get
Set
m_Address = Value
End Set
End Property
Private m_Address As String
Public Property Salary() As Integer
Get
Return m_Salary
End Get
Set
m_Salary = Value
End Set
End Property
Private m_Salary As Integer
Public Function GetData() As List(Of [MyClass])
Dim c1 As New [MyClass]() With { _
Key .Name = "Ahmed1", _
Key .Address = "Mukalla", _
Key .Salary = 10 _
}
Dim c2 As New [MyClass]() With { _
Key .Name = "Ahmed2", _
Key .Address = "Mukalla", _
Key .Salary = 20 _
}
Dim c3 As New [MyClass]() With { _
Key .Name = "Ahmed3", _
Key .Address = "Mukalla", _
Key .Salary = 30 _
}
Dim c4 As New [MyClass]() With { _
Key .Name = "Ahmed4", _
Key .Address = "Mukalla", _
Key .Salary = 40 _
}
Dim c5 As New [MyClass]() With { _
Key .Name = "Ahmed5", _
Key .Address = "Mukalla", _
Key .Salary = 50 _
}
Dim lmc As New List(Of [MyClass])()
lmc.Add(c1)
lmc.Add(c2)
lmc.Add(c3)
lmc.Add(c4)
lmc.Add(c5)
lmc.Add(c5)
Return lmc
End Function
End Class
End Namespace
بالنسبة لتحويل الحقل لـ
Combo
من الخصائص
Combo
من الخصائص
æåÐÇ ãæÞÚ íÞæã
موقع لتحويل الاكواد
C# & VB
موقع لتحويل الاكواد
C# & VB
C# to VB Or VB to C#
سبحان الله والحمدلله ولا إله إلا الله والله أكبر
اللهم اغْفِرْ لِلمؤمنين والمؤمنات والمسلمين والمسلمات الأحياء منهم والأموات


