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 มันเป็นเหมือนในรูปอ่ะครับแต่ผมต้องการให้เวลาคลิกเลือกแถวใน DataGridView ให้เลือกแถวทั้งหมดอ่ครับ



 

ตอนที่ผมคลิกเลือกแถวใน DataGridView มันเป็นเหมือนในรูปอ่ะครับแต่ผมต้องการให้เวลาคลิกเลือกแถวใน DataGridView ให้เลือกแถวทั้งหมดอ่ครับ

 



Topic : 049224



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



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




datagridview

รูปตัวอย่าง ตอนที่ผมคลิกเลือกแถวใน DataGridView มันเป็นเหมือนในรูปอ่ะครับแต่ผมต้องการให้เวลาคลิกเลือกแถวใน datagridview ให้เลือกแถวทั้งหมดอ่ครับจะต้องเพิ่มคำสั่งอะไรหรือครับ

อีกเรื่องครับถ้าผมจะจัด header ของ DataGridView ให้อยู่ตรงกลาง ตัวหนา และใส่สีพื้นหลัง จะใช้คำสั่งอ่ะไรหรอครับ รบกวนด้วยครับ


ขอบคุณครับ



Tag : .NET, VS 2010 (.NET 4.x)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-09-23 14:20:13 By : GhostLocal View : 5918 Reply : 8
 

 

No. 1



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

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

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


Code (VB.NET)
 gridview.Rows(Me.BindingContext(ds, "table").Position).Selected = True


ส่วนฟร้อนมันแต่งได้ในดีไซด์ หรือ event CellFormatting








ประวัติการแก้ไข
2010-09-23 15:38:58
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-23 15:38:30 By : noptalent
 


 

No. 2



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



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


ลองแล้วครับไม่ได้อ่ะครับ ว่าแต่เอาไปเพิ่มตรงไหนหรอครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-23 15:51:47 By : GhostLocal
 

 

No. 3



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

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

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


เอาเป็นว่าลองเอาโค้ดนายมาดูดีกว่า
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-23 20:58:12 By : noptalent
 


 

No. 4



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



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


Code (VB.NET)
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.OleDb
Imports System.Windows.Forms
Public Class FrmInsertJob
    Inherits System.Windows.Forms.Form
    'เหตุการณ์ตอนโหลดฟอร์ม
    Private Sub FrmInsertJob_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Me.WindowState = FormWindowState.Maximized
        Cursor.Current = Cursors.WaitCursor
        Dim sqlCountry As String = ""
        Dim dsCountry As New DataSet
        sqlCountry = "SELECT * FROM Country"
        da = New OleDbDataAdapter(sqlCountry, ConnectAccess)
        da.Fill(dsCountry, "AllCountry")
        If dsCountry.Tables("AllCountry").Rows.Count <> 0 Then
            Try
                ConToData()         'เชื่อมต่อกับฐานข้อมูล
                IsFind = True
                With Country
                    .DataSource = dsCountry.Tables("AllCountry")
                    .DisplayMember = "Country"
                    .ValueMember = "Countryid"
                End With
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        Else
            IsFind = False
            Country.DataSource = Nothing
        End If
        Cursor.Current = Cursors.Default
        ShowgrdKholer()

        cmdEdit.Enabled = False
    End Sub
Private Sub ShowgrdKholer()
        Dim sqlKholer As String = ""
        sqlKholer = "SELECT * FROM Detail ORDER BY Detailid ASC"
        da.SelectCommand.CommandText = sqlKholer
        ds.Clear()
        da.Fill(ds, "ShowKholer")
        'ถ้ามีอย่างน้อย 1 เร็คคอร์ดแล้ว
        If (ds.Tables("ShowKholer").Rows.Count <> 0) Then
            ConToData()
            IsFind = True
            With grdKholer
                .DataSource = ds.Tables("ShowKholer")
                .ReadOnly = True
                .RowHeadersVisible = False
                .AutoGenerateColumns = False
                .ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
                .AlternatingRowsDefaultCellStyle.BackColor = Color.LightYellow
            End With
        Else
            IsFind = False
            grdKholer.DataSource = Nothing
        End If
    End Sub
'เหตุการณ์ดับเบิ้ลคลิกที่ DataGridView
    Private Sub grdKholer_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grdKholer.CellDoubleClick
        Dim UserSelectRow As Long = 0
        UserSelectRow = grdKholer.CurrentRow.Index
        If IsFind = True Then
            'Data(1)
            DetailID = CInt(grdKholer.CurrentRow.Cells(0).Value)
            txtJob.Text = CStr(grdKholer.CurrentRow.Cells(1).Value.ToString)
            lblJobfef1.Text = CStr(grdKholer.CurrentRow.Cells(1).Value.ToString)
            lblJobfef2.Text = CStr(grdKholer.CurrentRow.Cells(1).Value.ToString)
            lblJobfef3.Text = CStr(grdKholer.CurrentRow.Cells(1).Value.ToString)
            ReqtoPlant.Value = CDate(grdKholer.CurrentRow.Cells(2).Value)
            ShipperName.Text = CStr(grdKholer.CurrentRow.Cells(3).Value.ToString)
            Mode.Text = CStr(grdKholer.CurrentRow.Cells(4).Value.ToString)
            PO.Text = CStr(grdKholer.CurrentRow.Cells(5).Value.ToString)
            INV.Text = CStr(grdKholer.CurrentRow.Cells(6).Value.ToString)
            ETD.Value = CDate(grdKholer.CurrentRow.Cells(7).Value)
            ATD.Value = CDate(grdKholer.CurrentRow.Cells(8).Value)
            ETA.Value = CDate(grdKholer.CurrentRow.Cells(9).Value)
            ATA.Value = CDate(grdKholer.CurrentRow.Cells(10).Value)
            FWDR.Text = CStr(grdKholer.CurrentRow.Cells(11).Value.ToString)
            GrossWeight.Text = CStr(CInt(grdKholer.CurrentRow.Cells(12).Value))
            Quantity.Text = CStr(CInt(grdKholer.CurrentRow.Cells(13).Value))
            Unit.Text = CStr(grdKholer.CurrentRow.Cells(14).Value.ToString)
            ICLCBM.Text = CStr(CInt(grdKholer.CurrentRow.Cells(15).Value))
            size1x20.Text = CStr(CInt(grdKholer.CurrentRow.Cells(16).Value))
            size1x40.Text = CStr(CInt(grdKholer.CurrentRow.Cells(17).Value))
            size1x40HQ.Text = CStr(CInt(grdKholer.CurrentRow.Cells(18).Value))
            ContrnCBM.Text = CStr(grdKholer.CurrentRow.Cells(19).Value.ToString)
            Port.Text = CStr(grdKholer.CurrentRow.Cells(20).Value.ToString)
            Country.Text = CStr(grdKholer.CurrentRow.Cells(21).Value.ToString)
            BL_no.Text = CStr(grdKholer.CurrentRow.Cells(22).Value.ToString)
            DateDO.Value = CDate(grdKholer.CurrentRow.Cells(23).Value)
            Rcvd_Doc.Value = CDate(grdKholer.CurrentRow.Cells(24).Value)
            Starting.Value = CDate(grdKholer.CurrentRow.Cells(25).Value)
            Released.Value = CDate(grdKholer.CurrentRow.Cells(26).Value)
            PlanDelivery.Value = CDate(grdKholer.CurrentRow.Cells(27).Value)
            Delivery.Value = CDate(grdKholer.CurrentRow.Cells(28).Value)
            Delivery_Place.Text = CStr(grdKholer.CurrentRow.Cells(29).Value.ToString)
            Remark.Text = CStr(grdKholer.CurrentRow.Cells(30).Value.ToString)
            'Data(2)
            BG_Date.Value = CDate(grdKholer.CurrentRow.Cells(31).Value)
            BG_Amount.Text = CStr(grdKholer.CurrentRow.Cells(32).Value.ToString)
            ImportCustomer.Text = CStr(grdKholer.CurrentRow.Cells(33).Value.ToString)
            TypeOfEntry.Text = CStr(grdKholer.CurrentRow.Cells(34).Value.ToString)
            SKUNumber.Text = CStr(grdKholer.CurrentRow.Cells(35).Value.ToString)
            DetailOfGoods.Text = CStr(grdKholer.CurrentRow.Cells(36).Value.ToString)
            CIF.Text = CStr(CInt(grdKholer.CurrentRow.Cells(37).Value))
            HSCode.Text = CStr(CInt(grdKholer.CurrentRow.Cells(38).Value))
            TarrifRate.Text = CStr(grdKholer.CurrentRow.Cells(39).Value.ToString)
            Duty.Text = CStr(CInt(grdKholer.CurrentRow.Cells(40).Value))
            Vat.Text = CStr(CInt(grdKholer.CurrentRow.Cells(41).Value))
            Eprivilege.Text = CStr(grdKholer.CurrentRow.Cells(42).Value.ToString)
            Eduty.Text = CStr(CInt(grdKholer.CurrentRow.Cells(43).Value))
            Vat2.Text = CStr(CInt(grdKholer.CurrentRow.Cells(44).Value))
            CostSaving.Text = CStr(grdKholer.CurrentRow.Cells(45).Value.ToString)
            KPI_LeadTime.Value = CDate(grdKholer.CurrentRow.Cells(46).Value)
            Billing.Value = CDate(grdKholer.CurrentRow.Cells(47).Value)
            KPI_Billing.Value = CDate(grdKholer.CurrentRow.Cells(48).Value)
            Duty2.Text = CStr(CInt(grdKholer.CurrentRow.Cells(49).Value))
            DutyExcludedVat.Text = CStr(CInt(grdKholer.CurrentRow.Cells(50).Value))
            DueDateDuty.Value = CDate(grdKholer.CurrentRow.Cells(51).Value)
            'Data(3)
            Freight.Text = CStr(grdKholer.CurrentRow.Cells(52).Value.ToString)
            Exwork.Text = CStr(grdKholer.CurrentRow.Cells(53).Value.ToString)
            DO1.Text = CStr(grdKholer.CurrentRow.Cells(54).Value.ToString)
            OtherCharge.Text = CStr(grdKholer.CurrentRow.Cells(55).Value.ToString)
            Total.Text = CStr(grdKholer.CurrentRow.Cells(56).Value.ToString)
            ConsolBill.Text = CStr(grdKholer.CurrentRow.Cells(57).Value.ToString)
            FrtBillNo.Text = CStr(grdKholer.CurrentRow.Cells(58).Value.ToString)
            FrtBillDate.Value = CDate(grdKholer.CurrentRow.Cells(59).Value)
            TranSportation.Text = CStr(grdKholer.CurrentRow.Cells(60).Value.ToString)
            TotalAmount.Text = CStr(grdKholer.CurrentRow.Cells(61).Value.ToString)
            BillingMonth.Text = CStr(grdKholer.CurrentRow.Cells(62).Value.ToString)
            FrtFromUS.Text = CStr(grdKholer.CurrentRow.Cells(63).Value.ToString)
            SavingFrtCost.Text = CStr(grdKholer.CurrentRow.Cells(64).Value.ToString)
            rdoImport.Checked = CBool(grdKholer.CurrentRow.Cells(65).Value)
            rdoExport.Checked = CBool(grdKholer.CurrentRow.Cells(66).Value)
        End If
        TabControl1.SelectedTab = Data1

        cmdAdd.Enabled = False
        cmdEdit.Enabled = True
        cmdCancle.Enabled = True
    End Sub

โค้ตครับใส่ตรงไหนหรอครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-24 08:18:35 By : GhostLocal
 


 

No. 5



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

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

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


Code (VB.NET)
With grdKholer
              .DataSource = ds.Tables("ShowKholer")
              .ReadOnly = True
              .RowHeadersVisible = False
              .AutoGenerateColumns = False
              .ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
              .AlternatingRowsDefaultCellStyle.BackColor = Color.LightYellow  

              .Rows(Me.BindingContext(ds, "ShowKholer").Position).Selected = True
End With


ลองดูนะ ได้ไม่ได้ยังไงว่ากันอีกที


ประวัติการแก้ไข
2010-09-24 11:01:05
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-24 11:00:27 By : noptalent
 


 

No. 6



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



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


ได้แล้วครับอยู่ใน properties ตรง selectmode default เป็น RowHeaderSelect เปลี่ยนเป็น FullRowSelect ครับ ขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-28 14:21:56 By : GhostLocal
 


 

No. 7

Guest


ขอบคุณครับทั้งสองท่าน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-03-13 10:29:00 By : SuPER MoN
 


 

No. 8

Guest


ขอบคุณมากๆครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-22 14:53:55 By : ธีระวุฒิ
 

   

ค้นหาข้อมูล


   
 

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