Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > สร้าง Textbox + Button อยู่ในช่องเดี่ยวกันใน Datagridview รบกวนขอคำแนะนำด้วยครับ



 

สร้าง Textbox + Button อยู่ในช่องเดี่ยวกันใน Datagridview รบกวนขอคำแนะนำด้วยครับ

 



Topic : 119777



โพสกระทู้ ( 345 )
บทความ ( 2 )



สถานะออฟไลน์




ตามหัวข้อเลยครับ
สร้าง Textbox + Button อยู่ในช่องเดี่ยวกันใน Datagridview รบกวนขอคำชีแนะด้วยครับ

rew

อันนี้เป็นตัวอย่างจาก C# ผมไป Copy Code มาแปลงอีทีครับ
แต่มันยัง Error อยู่ไม่รู้จะแก้ตรงไหนครับ



ในส่วนของหน้าออกแบบ ทำการเพิ่มรูปภาพเสร็จหมดละ

หหห

ไไ


Code Code (VB.NET)
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Public Class Form1
    Private btnSelector As New Button()
    'สร้าง Buttnon
    Private pCase As Integer
    'สำหรับ เก็บส่วนของการเลือก Column

    Private Sub SelectorClick(ByVal sender As Object, ByVal e As EventArgs)
        Select Case pCase
            Case 1
                'value from dataGridView1_CellEnter
                If True Then
                    MessageBox.Show("Show Dialog here!!")
                    Exit Select
                End If
        End Select
    End Sub

    Private Sub CreateButton(ByRef myButton As Button)
        myButton.FlatStyle = FlatStyle.Flat
        myButton.FlatAppearance.BorderSize = 0
        myButton.Size = New Size(25, 19)
        myButton.ImageAlign = ContentAlignment.MiddleCenter
        myButton.FlatAppearance.MouseDownBackColor = Color.Transparent
        myButton.FlatAppearance.MouseOverBackColor = Color.Transparent
        myButton.BackColor = Color.Transparent
        myButton.Image = Properties.resources.search3
        'กำหนดรูปภาพ
        'myButton.Text = "...";
        myButton.Hide()
        myButton.Click += New EventHandler(AddressOf Me.SelectorClick)
        '--------------------------------------------
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CreateButton(btnSelector)
        DataGridView1.Controls.Add(btnSelector)

    End Sub

    Private Sub DataGridView1_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEnter
        If DataGridView1.Columns(e.ColumnIndex).Name = "Column1" Then
            pCase = 1
            Dim Loc As Rectangle = DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, False)
            Dim Wid As Integer = DataGridView1.CurrentCell.Size.Width
            btnSelector.Location = New Point(Loc.X - 25 + Wid, Loc.Y)
            btnSelector.Show()
        End If

    End Sub

    Private Sub DataGridView1_CellLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellLeave
        If btnSelector.Focused <> True Then
            btnSelector.Hide()
        End If

    End Sub
End Class



แต่ในส่วนของ Code มันยัง Error อยู่ครับ
myButton.Image = Properties.resources.search3
myButton.Click += New EventHandler(AddressOf Me.SelectorClick)

ww

อ้างอิง http://thaicodingclub.blogspot.com/2010/07/button-datagridview-step-by-step-cnet.html



Tag : .NET, Ms SQL Server 2005, VB.NET









ประวัติการแก้ไข
2015-11-07 10:21:45
2015-11-07 10:27:18
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-11-07 10:20:41 By : TheCom View : 1941 Reply : 6
 

 

No. 1



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook

https://www.thaicreate.com/community/csharp-datagridview-openfile-ban-ban.html






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-07 15:47:56 By : lamaka.tor
 


 

No. 2



โพสกระทู้ ( 345 )
บทความ ( 2 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 1 เขียนโดย : lamaka.tor เมื่อวันที่ 2015-11-07 15:47:56
รายละเอียดของการตอบ ::
https://www.thaicreate.com/community/csharp-datagridview-openfile-ban-ban.html
ผมลองละมันยัง Error อยู่ครับ


รบกวนช่วยดู Code Code (VB.NET)
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Public Class Form1
    Private btnSelector As New Button()
    'สร้าง Buttnon
    Private pCase As Integer
    'สำหรับ เก็บส่วนของการเลือก Column

    Private Sub SelectorClick(ByVal sender As Object, ByVal e As EventArgs)
        Select Case pCase
            Case 1
                'value from dataGridView1_CellEnter
                If True Then
                    MessageBox.Show("Show Dialog here!!")
                    Exit Select
                End If
        End Select
    End Sub

    Private Sub CreateButton(ByRef myButton As Button)
        myButton.FlatStyle = FlatStyle.Flat
        myButton.FlatAppearance.BorderSize = 0
        myButton.Size = New Size(30, 19)
        myButton.ImageAlign = ContentAlignment.MiddleCenter
        myButton.FlatAppearance.MouseDownBackColor = Color.Transparent
        myButton.FlatAppearance.MouseOverBackColor = Color.Transparent
        myButton.BackColor = Color.Transparent
        'myButton.Image = Properties.resources.search3
        myButton.Image = Image.FromFile(CurDir() + "\pic\SearchBc.png")

        'กำหนดรูปภาพ
        myButton.Hide()
        myButton.Click += New EventHandler(AddressOf Me.SelectorClick)

        '--------------------------------------------
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CreateButton(btnSelector)
        DataGridView1.Controls.Add(btnSelector)
    End Sub

    Private Sub DataGridView1_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEnter
        If DataGridView1.Columns(e.ColumnIndex).Name = "Column1" Then
            pCase = 1
            Dim Loc As Rectangle = DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, False)
            Dim Wid As Integer = DataGridView1.CurrentCell.Size.Width
            btnSelector.Location = New Point(Loc.X - 25 + Wid, Loc.Y)
            btnSelector.Show()
        End If
    End Sub

    Private Sub DataGridView1_CellLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellLeave
        If btnSelector.Focused <> True Then
            btnSelector.Hide()
        End If

    End Sub
End Class


ตอนนี้รูปขึ้นละครับ
11

เหลือการกำหนด Event การคลิกที่ยัง Error อยู่ครับ

myButton.Click += New EventHandler(AddressOf Me.SelectorClick)


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-09 16:23:16 By : TheCom
 

 

No. 3



โพสกระทู้ ( 345 )
บทความ ( 2 )



สถานะออฟไลน์


AddHandler myButton.Click, New EventHandler(AddressOf Me.SelectorClick) ได้ละครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-09 16:35:14 By : TheCom
 


 

No. 4



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-09 16:43:13 By : mr.win
 


 

No. 5



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-09 16:55:38 By : lamaka.tor
 


 

No. 6



โพสกระทู้ ( 345 )
บทความ ( 2 )



สถานะออฟไลน์


เขียนบทความให้แล้วครับ ตามนี้เลย
https://www.thaicreate.com/community/vb-datagridview-textbox-button.html

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-11-09 17:00:15 By : TheCom
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สร้าง Textbox + Button อยู่ในช่องเดี่ยวกันใน Datagridview รบกวนขอคำแนะนำด้วยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่