Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 78072

How to create GridViewTextBoxColumn with Button

$
0
0

Thank you for reply, I adopted second way.

I followed this tutorial creating-custom-cells (same as yours).

But I dont' understand how it exposes Click event of my GridViewTextButtonColumn class.

Here my codes:

01.PublicClassTextButtonCellElement
02.    InheritsGridDataCellElement
03. 
04.    PublicSubNew(ByValcolumn AsGridViewColumn, ByValrow AsGridRowElement)
05.        MyBase.New(column, row)
06.    EndSub
07. 
08.    Private_RadTextBoxControl AsRadTextBoxElement
09.    Private_RadButtonElement AsRadButtonElement
10. 
11.    ProtectedOverridesSubCreateChildElements()
12.        MyBase.CreateChildElements()
13. 
14.        _RadTextBoxControl = NewRadTextBoxElement()
15.        Me.Children.Add(_RadTextBoxControl)
16. 
17.        _RadButtonElement = NewRadButtonElement
18.        _RadButtonElement.Text = "..."
19.        _RadButtonElement.Margin = NewWindows.Forms.Padding(0, 1, 3, 1)
20.        AddHandler_RadButtonElement.Click, AddressOf_RadButtonElement_Click
21.        Me.Children.Add(_RadButtonElement)
22. 
23.    EndSub
24. 
25.    ProtectedOverridesSubDisposeManagedResources()
26.        RemoveHandler_RadButtonElement.Click, AddressOf_RadButtonElement_Click
27.        MyBase.DisposeManagedResources()
28.    EndSub
29. 
30.    ProtectedOverridesFunctionArrangeOverride(ByValfinalSize AsSizeF) AsSizeF
31.        IfMe.Children.Count = 2 Then
32.            DimprogressBarWidth AsSingle= finalSize.Width - _RadButtonElement.DesiredSize.Width
33.            DimprogressBarRect AsNewRectangleF(0, 0, progressBarWidth - 1, finalSize.Height)
34.            DimbuttonRect AsNewRectangleF(progressBarWidth + 1, 0, _RadButtonElement.DesiredSize.Width, finalSize.Height)
35.            Me.Children(0).Arrange(progressBarRect)
36.            Me.Children(1).Arrange(buttonRect)
37.        EndIf
38.        ReturnfinalSize
39.    EndFunction
40. 
41.    PublicShadowsEventClick(sender AsObject, e AsEventArgs)
42.    PrivateSub_RadButtonElement_Click(sender AsObject, e AsEventArgs)
43.        RaiseEventClick(sender, e)
44.    EndSub
45. 
46.    ProtectedOverridesSubSetContentCore(ByValvalue AsObject)
47.        IfMe.Value IsNot NothingAndAlsoMe.Value IsNot DBNull.Value Then
48.            Me._RadTextBoxControl.Text = CStr(Me.Value)
49.        EndIf
50.    EndSub
51. 
52.    ProtectedOverridesReadOnlyPropertyThemeEffectiveType() AsType
53.        Get
54.            ReturnGetType(GridDataCellElement)
55.        EndGet
56.    EndProperty
57. 
58.    PublicOverridesFunctionIsCompatible(ByValdata AsGridViewColumn, ByValcontext AsObject) AsBoolean
59.        ReturnTypeOfdata IsGridViewTextButtonColumn AndAlsoTypeOfcontext IsGridDataRowElement
60.    EndFunction
61. 
62.EndClass
63. 
64.PublicClassGridViewTextButtonColumn
65.    InheritsGridViewDataColumn
66.    PublicSubNew(ByValfieldName AsString)
67.        MyBase.New(fieldName)
68. 
69.    EndSub
70. 
71.    Private_GridViewRowInfo AsGridViewRowInfo
72.    PublicPropertyGridViewRowInfo() AsGridViewRowInfo
73.        Get
74.            Return_GridViewRowInfo
75.        EndGet
76.        Set(ByValvalue AsGridViewRowInfo)
77.            _GridViewRowInfo = value
78.        EndSet
79.    EndProperty
80. 
81.    PublicSubClick(sender AsObject, e AsEventArgs)
82.        ThrowNewNotImplementedException()
83.    EndSub
84. 
85.    PublicOverridesFunctionGetCellType(ByValrow AsGridViewRowInfo) AsType
86. 
87.        IfTypeOfrow IsGridViewDataRowInfo Then
88.            ReturnGetType(TextButtonCellElement)
89.        EndIf
90.        ReturnMyBase.GetCellType(row)
91. 
92.        _GridViewRowInfo = row
93.    EndFunction
94.EndClass

Viewing all articles
Browse latest Browse all 78072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>