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 > อยากสั่งทำงานให้ DataGridView เลื่อนลงทีละ Cell หรือกดปุ่มทาง Button ให้ DataGridView แนะนำหน่อยคับ



 

อยากสั่งทำงานให้ DataGridView เลื่อนลงทีละ Cell หรือกดปุ่มทาง Button ให้ DataGridView แนะนำหน่อยคับ

 



Topic : 125160



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



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




อยากสั่งทำงานให้Datagridview เลื่อนลงทีละCell หรือกดปุ่มทางBUTTONให้Datagridview แนะนำหน่อยคับ



Tag : .NET







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-10-29 19:16:53 By : prapusak View : 1605 Reply : 9
 

 

No. 1



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



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


เปลี่ยน indicator ของ navigator

http://stackoverflow.com/questions/11158044/datagridview-navigating-to-next-row






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-10-30 04:28:27 By : Chaidhanan
 


 

No. 2



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



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

Datagridview มันคลิกได้เลยไม่ใช่รึครับ

งงตรง อยากสั่งทำงานให้Datagridview เลื่อนลงทีละCell

แถมกดคีย์บอร์ด ขึ้น/ลง ง่ายกว่าคลิกอีกนะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-10-30 11:15:55 By : lamaka.tor
 

 

No. 3



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



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


ในส่วนใช้เมาส์คลิกใช้คีย์บอร์ดเลื่อนขึ้นลงใช้งานได้ปกติคับ

แต่เวลาเราไปกดปุ่มอื่นนอกDatagridview แล้วกดลูกศรมันจะไม่ทำงานต้องไปคลิกมันก่อน

ก็เลยจะทำปุ่มเพื่อสั่งให้มันทำงานขึ้นลงคับโดยที่ไม่ต้องไปกดDatagridview
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-10-30 11:54:38 By : prapusak
 


 

No. 4



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



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

ส่วนใหญ่ที่เห็นๆก็จะประมาณใช้

1. ใช้ navigator
ก็ต้องกดอยู่ดี
2. ใช้ binding source
เราสามารถใช้ Control.KeyPress Event เพื่อเรียกใช้งาน
MoveFirst() MoveLast() MoveNext() MovePrevious()
อย่างพวก form textbox หรืออื่นๆ
แบบนี้ user ก็ใช้งานสะดวกดีครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-10-30 20:31:49 By : lamaka.tor
 


 

No. 5



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



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


ได้แล้วคับ ขอบคุณมาก
ใช้DATABASSBindingSource.MoveNext() แค่นี้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-10-30 23:19:11 By : prapusak
 


 

No. 6



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



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


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-10-31 08:54:45 By : lamaka.tor
 


 

No. 7

Guest


Code (VB.NET)

x0x01

Public Class Form2

    Private dtRegion As New DataTable("dtRegion") 'ภาค
    Private dtZone As New DataTable("dtZone") 'เขตการขาย/โซน
    Private parentBS As New BindingSource() 'อนุมานว่า ภาค
    Private childBS As New BindingSource() 'อนุนมานว่า เขตการขาย/โซน
    Private filteredChildBS As New BindingSource() 'อนุมานได้ว่า ภาค/โซน 

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'add columns/rows in the Region table      
        dtRegion.Columns.Add(New DataColumn() With {.ColumnName = "RegionID", .DataType = GetType(Integer)})
        dtRegion.Columns.Add(New DataColumn() With {.ColumnName = "RegionDescription", .DataType = GetType(String)})
        dtRegion.Rows.Add(1, "ภาคเหนือ")
        dtRegion.Rows.Add(2, "ภาคใต้")
        dtRegion.Rows.Add(3, "ภาคตะวันตก")
        dtRegion.Rows.Add(4, "ภาคตะวันออก")

        'add some column/rows in the Zone table
        dtZone.Columns.Add(New DataColumn() With {.ColumnName = "ZoneID", .DataType = GetType(Integer)})
        dtZone.Columns.Add(New DataColumn() With {.ColumnName = "ZoneDescription", .DataType = GetType(String)})
        dtZone.Columns.Add(New DataColumn() With {.ColumnName = "RegionID", .DataType = GetType(Integer)})
        dtZone.Rows.Add(1, "ภาคเหนือ ผิวขาว", 1)
        dtZone.Rows.Add(2, "ภาคเหนือ อวบอูม", 1)
        dtZone.Rows.Add(1, "ภาคใต้ ผิวขาว", 2)
        dtZone.Rows.Add(2, "ภาคใต้ หอยงาม", 2)
        dtZone.Rows.Add(1, "ภาคตะวันตก ผิวขาว", 3)
        dtZone.Rows.Add(2, "ภาคตะวันตก หอยใหญ่", 3)
        dtZone.Rows.Add(1, "ภาคตะวันออก ผิวขาว", 4)
        dtZone.Rows.Add(2, "ภาคตะวันออก ระยองฮิสั้น จันฮิยาว", 4)
        dtZone.Rows.Add(3, "ภาคตะวันออก หอยหอม", 4)

        'Bound to a datatable
        Dim dtYET As New DataTable("dtYET")
        dtYET.Columns.Add(New DataColumn() With {.ColumnName = "RegionID", .DataType = GetType(Integer)})
        dtYET.Columns.Add(New DataColumn() With {.ColumnName = "ZoneID", .DataType = GetType(Integer)})
        '**************************************
        'Tricks
        '**************************************
        dtYET.Rows.Add(1, 1)
        dtYET.Rows.Add(2, 2)
        dtYET.Rows.Add(3, 3)
        dtYET.Rows.Add(4, 4)

        ' set up ParentBS and ChildBS and filteredChildBS
        parentBS.DataSource = dtRegion
        childBS.DataSource = dtZone

        filteredChildBS.DataSource = dtZone

        'bind the regionComboBoxColumn to the parentBS
        Me.regionComboBoxColumn.DataSource = parentBS
        Me.regionComboBoxColumn.DisplayMember = "RegionDescription"
        Me.regionComboBoxColumn.ValueMember = "RegionID"

        'bind the ZoneComboBoxColumn to the childBS
        Me.ZoneComboBoxColumn.DataSource = childBS
        Me.ZoneComboBoxColumn.DisplayMember = "ZoneDescription"
        Me.ZoneComboBoxColumn.ValueMember = "ZoneID"

        DataGridView1.AutoGenerateColumns = False
        DataGridView1.DataSource = dtYET
        DataGridView1.Columns(0).DataPropertyName = "RegionID"
        DataGridView1.Columns(1).DataPropertyName = "ZoneID"
    End Sub

    Private Sub DataGridView1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
        Try
            If e.ColumnIndex = regionComboBoxColumn.Index Then
                If Me.DataGridView1.DataSource IsNot Nothing Then
                    If Me.DataGridView1.DataSource.GetType() = GetType(DataTable) Then
                        Me.DataGridView1.Rows(e.RowIndex).Cells(ZoneComboBoxColumn.Index).Value = DBNull.Value
                    Else
                        Me.DataGridView1.Rows(e.RowIndex).Cells(ZoneComboBoxColumn.Index).Value = Nothing
                    End If
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub DataGridView1_DataError(sender As Object, e As DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
        If e.ColumnIndex <> ZoneComboBoxColumn.Index Then
            'MessageBox.Show("หอยงาม")
        End If
    End Sub

    Private Sub DataGridView1_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
        If Me.DataGridView1.CurrentCell.ColumnIndex = ZoneComboBoxColumn.Index Then
            Dim control As DataGridViewComboBoxEditingControl = TryCast(e.Control, DataGridViewComboBoxEditingControl)
            Dim bs As BindingSource = TryCast(control.DataSource, BindingSource)
            If bs IsNot Nothing Then
                ' set the filteredChildBS as the DataSource of the editing control
                TryCast(e.Control, ComboBox).DataSource = filteredChildBS
                Dim regionvalue As Object = Me.DataGridView1.Rows(Me.DataGridView1.CurrentCell.RowIndex).Cells(regionComboBoxColumn.Index).Value
                If regionvalue Is DBNull.Value OrElse regionvalue Is Nothing Then
                    filteredChildBS.Filter = "RegionID=-1"
                Else
                    filteredChildBS.Filter = "RegionID=" + regionvalue.ToString()
                End If
                ' set the SelectedValue property of the editing control
                If Me.DataGridView1.CurrentCell.Value IsNot DBNull.Value AndAlso Me.DataGridView1.CurrentCell.Value IsNot Nothing Then
                    control.SelectedValue = Me.DataGridView1.CurrentCell.Value
                End If
            End If
        End If
    End Sub

    Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean
        If keyData = Keys.Enter Then
            SendKeys.Send("{TAB}")
            Return True
        End If
        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function
End Class

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-10-31 13:52:01 By : หน้าฮี
 


 

No. 8

Guest


จาก #NO 7 ผมไม่เขียน Windows Application มานาน จนลืมไปเลย
--- พอจะใช้ แม่งเสือกลืม (เซ็งจริงฯ)
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-10-31 14:03:25 By : หน้าฮี
 


 

No. 9

Guest


จาก #NO7 - #NO8 บอกให้เอาบุญก็ได้ว่า เวลาใช้งานจริงฯ
ผมใช้แบบนี้ (ขั้นต่ำ)
Code (VB.NET)
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Drawing
<ToolboxBitmap(GetType(DataGridView))> _
Public Class usrCtrGridControlExt : Inherits DataGridView
'...
'...
'...
'
End Class


ผมไม่ได้ใช้แบบโปรแกรมเมอร์ (ทึ่มฯเบลอฯ งงฯ (ไม่ค่อยฉลาด))
ประมาณนั้น
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-10-31 14:10:15 By : หน้าฮี
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อยากสั่งทำงานให้ DataGridView เลื่อนลงทีละ Cell หรือกดปุ่มทาง 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 อัตราราคา คลิกที่นี่