도움을 주셔서 감사합니다.ComponentOne True DBGrid 사용자 지정 셀 만들기
이것은 Componentone의 True DBGrid와 관련되어 있으므로 답변을 기대하기 가장 좋은 장소는 아닐지 모르지만이 시점에서 나는 할 수있는 한 많이 해낸 것처럼 느낍니다. 샷.
지난 몇 일 동안 True DBGrid에서 사용자 지정 셀을 만드는 방법을 알아 내려고 노력한 결과, 현재 막혀 있습니다. 내가 찾을 수있는만큼 많은 문서를 살펴 보았지만 True DBGrid에 대한 모든 자습서는 아래 첨부 된 그림에 나와 있습니다. 여기
만약 당신이 나는 사용자 지정 컨트롤 그들이에 클릭 한 셀에 표시 얻을 수있는 셀을 두 번 클릭합니다. 그러나 셀을 클릭 할 때뿐만 아니라 항상 볼 수있게하려면이 셀을 displayColumn이 아닌 행 자체를 기반으로하고 싶습니다. 지금은 "DisplayColumn.DataColumn.Editor"를 다시로드합니다. 다른 셀을 클릭 할 때마다 이 성능을위한 코드는 아래와 같습니다.
' Retrieve Column
Dim objPrefDisplayColumn As C1.Win.C1TrueDBGrid.C1DisplayColumn = Me.TestGrid.Splits(0).DisplayColumns("ColumnFieldName")
'Retrieve data from database
Dim data As DataTable = ' My call to database table goes here Retrieve data that relates to row
' Create Custom Controller and Insert Data from table into it
Dim prvNewCellList As New TestCellList
prvNewCellList.LabelButtonHeight = Me.TestGrid.RowHeight/pref.Rows.Count
prvNewCellList.LabelWidth = (objPrefDisplayColumn.Width * 0.9)
prvNewCellList.ButtonWidth = (objPrefDisplayColumn.Width * 0.1)
prvNewCellList.Action_LoadUI(data)
' Assign Custom Controller to Column
objPrefDisplayColumn.DataColumn.Editor = prvNewCellList
objPrefDisplayColumn.Button = True
objPrefDisplayColumn.ButtonAlways = True
objPrefDisplayColumn.DropDownList = False
objPrefDisplayColumn.DataColumn.DropDown = Nothing
는 내가 이미지가 보여처럼 그들은, 사용자 정의 "DataGridViewTextBoxCell"에 두는 곳 아래 링크와 같은 DataGridView에 대한 자습서를 볼 때이 가능해야한다 알고있다.
Turtorial for Custom DataGridViewCells
내가 TrueDBGrid에 관한 읽은 내용에 근거하고, ComponentOne은 가능성이 가장 높은 TrueDBGrid을 만들기위한 템플릿으로 DataGridView를 사용 예상 논리는, 나는 매우 유사하다 맞춤형 세포를 생성하는 방법을 기대. 그러나 아래에 표시된 것처럼 TrueDBGrid를 사용하여이 예제를 다시 만들려고하면 "DataGridViewColumn"을 허용하지 않는 열을 발견했으며 "C1DataColumn"으로 변경하여 기대를 충족 시키려고 시도했을 때 클래스에 " CellTemplate "을 사용하여 사용자 지정 셀을 만들 수 있습니다. 이 시점에서 저는 TrueDBGrid 개발 과정에서 커스텀 셀의 기능을 잊어 버렸다고 생각합니다.Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim col As New DataGridViewRolloverCellColumn()
Me.TestGrid.Columns.Add(col)
Catch ex As Exception
MsgBox("error arrose", vbInformation, "error")
End Try
End Sub
End Class
Public Class DataGridViewRolloverCellColumn
Inherits DataGridViewColumn
Public Sub New()
Me.CellTemplate = New DataGridViewRolloverCell()
End Sub
End Class
Public Class DataGridViewRolloverCell
Inherits DataGridViewTextBoxCell
Protected Overrides Sub Paint(_
ByVal graphics As Graphics, _
ByVal clipBounds As Rectangle, _
ByVal cellBounds As Rectangle, _
ByVal rowIndex As Integer, _
ByVal elementState As DataGridViewElementStates, _
ByVal value As Object, _
ByVal formattedValue As Object, _
ByVal errorText As String, _
ByVal cellStyle As DataGridViewCellStyle, _
ByVal advancedBorderStyle As DataGridViewAdvancedBorderStyle, _
ByVal paintParts As DataGridViewPaintParts)
' Call the base class method to paint the default cell appearance.
MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, _
value, formattedValue, errorText, cellStyle, _
advancedBorderStyle, paintParts)
' Retrieve the client location of the mouse pointer.
Dim cursorPosition As Point = _
Me.DataGridView.PointToClient(Cursor.Position)
' If the mouse pointer is over the current cell, draw a custom border.
If cellBounds.Contains(cursorPosition) Then
Dim newRect As New Rectangle(cellBounds.X + 1, _
cellBounds.Y + 1, cellBounds.Width - 4, _
cellBounds.Height - 4)
graphics.DrawRectangle(Pens.Red, newRect)
End If
End Sub
End Class
다시 한번 감사 시간 후 도움
FlexGrid와 함께 사용해 보셨습니까? 처음에는 덜 직관적으로 보일지 모르지만 일단 전반적인 요점을 얻으면 사실 trueDbGrid보다 훨씬 다양합니다. –
우리가 이미 다른 기능과 함께 작동하는 TrueDBGrid를 가지고있는 곳 중 하나이며, 우리는 응용 프로그램의 모든 테이블에이 도구를 사용합니다. 그래서 우리가 그것을 피할 수 있다면 최선이라고 생각합니다. – Lightbarrier