الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيفية استخدام Contex Menu ؟؟

بدأه ابوخالد العيدروس في 31 يناير 2009 · 3 رد · 608 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكــم ورحمـة الله وبركاتــه

سؤالي عن كيفية استخدام القائمة الجانبية Contex Menu

1- والمطلوب ايضا تعبئة القائمة من خلال قيم موجودة في قاعدة البيانات

وهذه النقطة قمت بتنفيذها ولكن اذا كان لديكم اي اضافة فلا تبخلوا علينا بها ...

ولكن يوجد مشكلة وهي ظهور القائمة مرتين ولا اعلم ماهو السبب

2- والاهم من هذا هو عند النقر او اختيار عنصر محدد موجود في القائمة اريد ان يتم كتابة هذا العنصر في مربع النص TextBox ؟؟

وقد قمت بارفاق مثال لما قمت به حتى الان ...

واذا كان هناك اي استفسار فانا حاضر ...

ولكم كل الشكر والتقدير

UsingContexMenu.rar

#2

السلام عليكــم ورحمـة الله وبركاتــه

غير الكود بهذا الشكل

 

[color= #000000; font-weight: bold;]Public [color= #000000; font-weight: bold;]Class Form1

    Inherits [color= #990000;]System[color= #339933;].Windows[color= #339933;].Forms[color= #339933;].Form

 

[color= #666666; font-style: italic;]#Region " Windows Form Designer generated code "

 

    [color= #000000; font-weight: bold;]Public Sub [color= #000000; font-weight: bold;]New[color= #009900;]([color= #009900;])

        MyBase[color= #339933;].[color= #000000; font-weight: bold;]New[color= #009900;]([color= #009900;])

 

        [color= #0000ff;]'This call is required by the Windows Form Designer.

[color= #0000ff;]        InitializeComponent()

 

[color= #0000ff;]        'Add any initialization after the InitializeComponent[color= #009900;]([color= #009900;]) call

 

    [color= #990000;]End Sub

 

    [color= #0000ff;]'Form overrides dispose to clean up the component list.

[color= #0000ff;]    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

[color= #0000ff;]        If disposing Then

[color= #0000ff;]            If Not (components Is Nothing) Then

[color= #0000ff;]                components.Dispose()

[color= #0000ff;]            End If

[color= #0000ff;]        End If

[color= #0000ff;]        MyBase.Dispose(disposing)

[color= #0000ff;]    End Sub

 

[color= #0000ff;]    'Required by the Windows Form Designer

    [color= #000000; font-weight: bold;]Private components [color= #b1b100;]As [color= #990000;]System[color= #339933;].ComponentModel[color= #339933;].IContainer

 

    [color= #0000ff;]'NOTE: The following procedure is required by the Windows Form Designer

[color= #0000ff;]    'It can be modified using the Windows Form Designer[color= #339933;].  

    [color= #0000ff;]'Do not modify it using the code editor.

[color= #0000ff;]    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox

[color= #0000ff;]    Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu

[color= #0000ff;]    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

[color= #0000ff;]        Me.TextBox1 = New System.Windows.Forms.TextBox

[color= #0000ff;]        Me.ContextMenu1 = New System.Windows.Forms.ContextMenu

[color= #0000ff;]        Me.SuspendLayout()

[color= #0000ff;]        '

        [color= #0000ff;]'TextBox1

[color= #0000ff;]        '

        Me[color= #339933;].TextBox1[color= #339933;].ContextMenu [color= #339933;]= Me[color= #339933;].ContextMenu1

        Me[color= #339933;].TextBox1[color= #339933;].Location [color= #339933;]= [color= #000000; font-weight: bold;]New [color= #990000;]System[color= #339933;].Drawing[color= #339933;].Point[color= #009900;]([color= #cc66cc;]32[color= #339933;], [color= #cc66cc;]72[color= #009900;])

        Me[color= #339933;].TextBox1[color= #339933;].Name [color= #339933;]= [color= #0000ff;]"TextBox1"

        Me[color= #339933;].TextBox1[color= #339933;].Size [color= #339933;]= [color= #000000; font-weight: bold;]New [color= #990000;]System[color= #339933;].Drawing[color= #339933;].Size[color= #009900;]([color= #cc66cc;]336[color= #339933;], [color= #cc66cc;]20[color= #009900;])

        Me[color= #339933;].TextBox1[color= #339933;].TabIndex [color= #339933;]= [color= #cc66cc;]0

        Me[color= #339933;].TextBox1[color= #339933;].Text [color= #339933;]= [color= #0000ff;]""

        [color= #0000ff;]'

[color= #0000ff;]        'Form1

        [color= #0000ff;]'

[color= #0000ff;]        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

[color= #0000ff;]        Me.ClientSize = New System.Drawing.Size(400, 266)

[color= #0000ff;]        Me.ContextMenu = Me.ContextMenu1

[color= #0000ff;]        Me.Controls.Add(Me.TextBox1)

[color= #0000ff;]        Me.Name = "Form1"

[color= #0000ff;]        Me.Text = "Form1"

[color= #0000ff;]        Me.ResumeLayout(False)

 

[color= #0000ff;]    End Sub

 

[color= #0000ff;]#End Region

 

[color= #0000ff;]    Public CON As New OleDb.OleDbConnection("Provider=Microsoft.jet.oleDB.4.0;Data Source=" & A
pplication.StartupPath & "[color= #000099; font-weight: bold;]AccMangerDB.mdb;")

 

[color= #0000ff;]    Private Sub TextBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseE
ventArgs) Handles TextBox1.MouseUp

[color= #0000ff;]        HandleMouseUp(TextBox1, e)

[color= #0000ff;]    End Sub

 

[color= #0000ff;]    Protected Sub ContextHandler(ByVal sender As System.Object, _

[color= #0000ff;]           ByVal e As System.EventArgs)

 

 

[color= #0000ff;]        Try

[color= #0000ff;]            ContextMenu1.MenuItems.Clear()

 

[color= #0000ff;]            Dim adp As New OleDb.OleDbDataAdapter("SELECT FValue FROM ASSITANCE", CON)

[color= #0000ff;]            Dim ds As New DataSet

 

[color= #0000ff;]            adp.Fill(ds, "ASSITANCE")

 

[color= #0000ff;]            If ds.Tables(0).Rows.Count > 0 Then

[color= #0000ff;]                Dim i As Integer

[color= #0000ff;]                For i = 0 To ds.Tables(0).Rows.Count - 1

[color= #0000ff;]                    ContextMenu1.MenuItems.Add(ds.Tables(0).Rows(i).Item(0), AddressOf MenuItem
_Click)

 

[color= #0000ff;]                Next

[color= #0000ff;]            End If

 

 

[color= #0000ff;]        Catch ex As Exception

[color= #0000ff;]            MsgBox(ex.Message)

[color= #0000ff;]        End Try

[color= #0000ff;]    End Sub

 

[color= #0000ff;]    Sub MenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)

[color= #0000ff;]        Dim item As MenuItem = sender

[color= #0000ff;]        Me.TextBox1.Text = item.Text

[color= #0000ff;]    End Sub

 

[color= #0000ff;]    Private Sub HandlePopup(ByVal sender As Object, ByVal e As System.EventArgs) _

[color= #0000ff;]                     Handles ContextMenu1.Popup

[color= #0000ff;]        ContextHandler(sender, e)

[color= #0000ff;]    End Sub

 

[color= #0000ff;]    Private Sub HandleMouseUp(ByVal Control As Object, ByVal e As System.Windows.Forms.MouseEve
ntArgs)

 

[color= #0000ff;]        '[color= #0000ff;]' Checking the Mouse right Button

[color= #0000ff;]        '[color= #b1b100;]If e[color= #339933;].Button [color= #339933;]= MouseButtons[color= #339933;].Right Then

        [color= #0000ff;]'    Control.ContextMenu.Show(Control, New Point(e.X, e.Y))

[color= #0000ff;]        '[color= #990000;]End [color= #b1b100;]If

 

    [color= #990000;]End Sub

[color= #990000;]End [color= #000000; font-weight: bold;]Class

[وسط]لا اله الا انت سبحانك انى كنت من الظالمين

[/وسط]

#4

واياكم اخي ابو خالد.

[وسط]لا اله الا انت سبحانك انى كنت من الظالمين

[/وسط]

مواضيع مشابهة