 |
|
WinApp ช่วยดูโค้ดให้หน่อยครับ พอเลือน scrollbar เพื่อ ขยายขนาดแล้ว ปุ่มไม่เลื่อนตามครับ |
|
 |
|
|
 |
 |
|
มันมี Property อยู่น่ะครับ ประมาณว่า Fixed หรือว่าจะขยายไปตามขนาดของหน้าจอครับ
|
 |
 |
 |
 |
Date :
2018-03-22 17:41:08 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
@lamaka.tor
--- มันไม่ง่ายที่จะทำ (ในเวลาที่จำกัด)
--- และมันคงไม่ยากเกินไปสำหรับคุณ (ถ้ามีเวลาพอ)
ผมมีโฟกัสหลายจุด แต่หนึ่งในนั้นไม่มีคำว่า "Windows Application" ปะปนอยู่ (แน่นอนว่าบางกรณีผมอาจจำเป็นต้องใช้มัน/เขียนเอง)
ผมแอบชื่นชมคุณนะ(สมัยผมยังเป็นเด็กฯ อายุไกล้ฯ 40 ณ.ตอนนั้น) (ผมแยกแยะออกเสมอ โดยแต่ละเหตุผล/สถานะการณ์)
Good Luck.
ปล. ...
|
 |
 |
 |
 |
Date :
2018-03-22 17:55:21 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จาก #NO 2 ถ้านับอายุจริงผมก็คงจะมากกว่าพวกคุณทุกฯคน (ไม่ยกเว้นแม้แต่ Admin/Chinaha/etc...)
--- ผมคิดถึงหลายฯคน อทิเช่น "คุณห้ามตอบเกินวันละสองกระทู้" (แต่ผมไม่มีวาสนาที่จะได้เจอเขาในชีวิตจริง)
------ แน่นอนว่า ผมมองในเง่มุมที่ดีดีเสมอสำหรับมนุษย์คนหนึ่ง
|
 |
 |
 |
 |
Date :
2018-03-22 18:08:41 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
@lamaka.tor ถ้าคุณคิดแบบธรรมชาติ ด้วยวัยอายุของผม
--- มันไม่ควรที่จะเขียนโปรแกรม (เอาให้สุดฯ ควรจะตายไปตั้งนานแล้ว) ถ้าคุณยังสงสัย
มันมีคำอธิบายได้ว่า "หลังความตาย" มักจะมีคนกล่าวถึงคนคนนั้นอยู่เสมอ อทิเช่น ไอสไตร์/นิวตัน/ปิกัสโซ/etc..
ชื่อเสียงมักจะมาได้หลังความตาย (อาจย้อนหลังไปอีกหลายร้อยปี ณ. วันเวลาปัจจุบัน)
+55555
|
 |
 |
 |
 |
Date :
2018-03-22 18:23:16 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันก็แปลกนะครับผมก๊อบโค้ดมาวางเลย
อันนี้รูปก่อนที่จะลาก ขยาย คอลัมน์

อันนี้คือ หลังจากที่ ผมลากเพื่อขยาย คอลัมน์

Code (VB.NET)
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 = WindowsApplication1.My.Resources.finds
' myButton.Image = Image.FromFile(CurDir() + "\pic\SearchBc.png")
'กำหนดรูปภาพ
myButton.Hide()
AddHandler 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 e.ColumnIndex = 0 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
|
 |
 |
 |
 |
Date :
2018-03-24 09:43:11 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมดูโค้ดจากที่ให้มาเหมือนกับว่ามันขาดไปบางอย่าง จริงอยู่ที่สร้างปุ่มให้แสดงมาใน Even CellEnter
ตอนขยายคอลัมภ์ให้ถึงแม้ว่า Cell ที่ถูกเลือกจะอยู่ที่เดิมก็ตามเพราะคำสั่งมันถูกทำไปแล้วตอนเลือก Cell ครั้งแรก
จึงเป็นสาเหตุว่าทำไมปุ่มมันถึงไม่ย้ายตามในขณะที่ขยายคอลัมภ์
จากโค้ดข้างบนผมลองปรับดังนี้
1. ย้าย Dim Loc As Rectangle และ Dim Wid As Integer ออกจาก Even CellEnter ไปไว้ข้างบนแทน เพื่อใช้ร่วมกันกับ Even ColumnWidthChanged ที่จะสร้างให้ย้ายปุ่มตอนขยายคอลัมภ์
Code (VB.NET)
Private btnSelector As New Button()
'สร้าง Buttnon
Private pCase As Integer
'สำหรับ เก็บส่วนของการเลือก Column
Dim Loc As Rectangle 'ย้ายมาข้างบน เพื่อใช้กับ DataGridView1_ColumnWidthChanged
Dim Wid As Integer 'ย้ายมาข้างบน เพื่อใช้กับ DataGridView1_ColumnWidthChanged
2. ปรับโค้ดใน Even CellEnter
Code (VB.NET)
Private Sub DataGridView1_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEnter
If e.ColumnIndex = 0 Then
pCase = 1
Loc = DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, False)
Wid = DataGridView1.CurrentCell.Size.Width
btnSelector.Location = New Point(Loc.X - 30 + Wid, Loc.Y)
btnSelector.Show()
End If
End Sub
3. เพิ่ม Event ColumnWidthChanged สำหรับย้ายปุ่มตอนขยายคอลัมภ์
Code (VB.NET)
Private Sub DataGridView1_ColumnWidthChanged(sender As Object, e As DataGridViewColumnEventArgs) Handles DataGridView1.ColumnWidthChanged
Loc = DataGridView1.GetCellDisplayRectangle(0, DataGridView1.CurrentRow.Index, False)
Wid = DataGridView1.CurrentCell.Size.Width
btnSelector.Location = New Point(Loc.X - 30 + Wid, Loc.Y)
End Sub
ผลของการทดสอบ
ก่อนขยาย

หลังขยาย

|
ประวัติการแก้ไข 2018-03-24 13:02:33
 |
 |
 |
 |
Date :
2018-03-24 12:26:26 |
By :
Itsaret |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทุกวันนี้มีใครเขาโง่ใช้ Web service บ้างว่ะ +55555
|
 |
 |
 |
 |
Date :
2018-03-25 00:00:10 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|