|
|
|
ตอนที่ผมคลิกเลือกแถวใน DataGridView มันเป็นเหมือนในรูปอ่ะครับแต่ผมต้องการให้เวลาคลิกเลือกแถวใน DataGridView ให้เลือกแถวทั้งหมดอ่ครับ |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองแล้วครับไม่ได้อ่ะครับ ว่าแต่เอาไปเพิ่มตรงไหนหรอครับ
|
|
|
|
|
Date :
2010-09-23 15:51:47 |
By :
GhostLocal |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอาเป็นว่าลองเอาโค้ดนายมาดูดีกว่า
|
|
|
|
|
Date :
2010-09-23 20:58:12 |
By :
noptalent |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับอยู่ใน properties ตรง selectmode default เป็น RowHeaderSelect เปลี่ยนเป็น FullRowSelect ครับ ขอบคุณครับ
|
|
|
|
|
Date :
2010-09-28 14:21:56 |
By :
GhostLocal |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับทั้งสองท่าน
|
|
|
|
|
Date :
2011-03-13 10:29:00 |
By :
SuPER MoN |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากๆครับ
|
|
|
|
|
Date :
2013-06-22 14:53:55 |
By :
ธีระวุฒิ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|