1
- Imports DevExpress.XtraGrid
1
+ Imports DevExpress.XtraGrid
2
2
Imports DevExpress.XtraGrid.Views.Base
3
3
Imports DevExpress.XtraGrid.Views.Grid
4
4
Imports System
5
5
Imports System.Data
6
6
Imports System.Windows.Forms
7
7
8
8
Namespace Q273845
9
- Partial Public Class Form1
10
- Inherits Form
9
+ Partial Public Class Form1
10
+ Inherits Form
11
11
12
- Public Sub New ()
13
- InitializeComponent()
14
- End Sub
12
+ Public Sub New ()
13
+ InitializeComponent()
14
+ End Sub
15
15
16
- Private Sub Form1_Load( ByVal sender As Object , ByVal e As EventArgs) Handles Me .Load
17
- productsBindingSource.DataSource = GetProductsDataTable()
18
- End Sub
16
+ Private Sub Form1_Load( ByVal sender As Object , ByVal e As EventArgs) Handles Me .Load
17
+ productsBindingSource.DataSource = GetProductsDataTable()
18
+ End Sub
19
19
20
- Private Function GetProductsDataTable() As DataTable
21
- Dim table As New DataTable()
22
- table.TableName = "Products"
23
- table.Columns.Add( New DataColumn( "ProductName" , GetType ( String )))
24
- table.Columns.Add( New DataColumn( "UnitsInStock" , GetType ( Integer )))
25
- table.Columns.Add( New DataColumn( "UnitPrice" , GetType ( Double )))
26
- table.Columns.Add( New DataColumn( "Category" , GetType ( String )))
27
- Dim random As New Random()
28
- For i As Integer = 0 To 19
29
- Dim index As Integer = i + 1
30
- table.Rows.Add( "Product " & index, random.Next( 1 , 20 ), Math.Round(random.NextDouble() * 1000 , 3 ), "Category " & i Mod 7 )
31
- Next i
32
- Return table
33
- End Function
20
+ Private Function GetProductsDataTable() As DataTable
21
+ Dim table As DataTable = New DataTable()
22
+ table.TableName = "Products"
23
+ table.Columns.Add( New DataColumn( "ProductName" , GetType ( String )))
24
+ table.Columns.Add( New DataColumn( "UnitsInStock" , GetType ( Integer )))
25
+ table.Columns.Add( New DataColumn( "UnitPrice" , GetType ( Double )))
26
+ table.Columns.Add( New DataColumn( "Category" , GetType ( String )))
27
+ Dim random As Random = New Random()
28
+ For i As Integer = 0 To 20 - 1
29
+ Dim index As Integer = i + 1
30
+ table.Rows.Add( "Product " & index, random.[ Next] ( 1 , 20 ), Math.Round(random.NextDouble() * 1000 , 3 ), "Category " & i Mod 7 )
31
+ Next
32
+ Return table
33
+ End Function
34
34
35
- Private Sub gridView1_CustomDrawFooterCell( ByVal sender As Object , ByVal e As FooterCellCustomDrawEventArgs) Handles gridView1.CustomDrawFooterCell
36
- If e.Column Is colPrice Then
37
- e.Info.DisplayText = (Convert.ToDecimal(colUnitPrice.SummaryItem.SummaryValue) * Convert.ToDecimal(colUnitsInStock.SummaryItem.SummaryValue)).ToString()
38
- End If
39
- End Sub
35
+ Private Sub gridView1_CustomDrawFooterCell( ByVal sender As Object , ByVal e As FooterCellCustomDrawEventArgs) Handles gridView1.CustomDrawFooterCell
36
+ If e.Column Is colPrice Then e.Info.DisplayText = (Convert.ToDecimal(colUnitPrice.SummaryItem.SummaryValue) * Convert.ToDecimal(colUnitsInStock.SummaryItem.SummaryValue)).ToString()
37
+ End Sub
40
38
41
- Private Sub gridView1_CustomDrawRowFooterCell( ByVal sender As Object , ByVal e As FooterCellCustomDrawEventArgs) Handles gridView1.CustomDrawRowFooterCell
42
- If e.Column Is colPrice Then
43
- Dim view As GridView = DirectCast (sender, GridView)
44
- e.Info.DisplayText = (Convert.ToDecimal(view.GetGroupSummaryValue(e.RowHandle, CType (view.GroupSummary( "UnitPrice" ), GridGroupSummaryItem))) * Convert.ToDecimal(view.GetGroupSummaryValue(e.RowHandle, CType (view.GroupSummary( "UnitsInStock" ), GridGroupSummaryItem)))).ToString()
45
- End If
46
- End Sub
39
+ Private Sub gridView1_CustomDrawRowFooterCell( ByVal sender As Object , ByVal e As FooterCellCustomDrawEventArgs) Handles gridView1.CustomDrawRowFooterCell
40
+ If e.Column Is colPrice Then
41
+ Dim view As GridView = CType (sender, GridView)
42
+ e.Info.DisplayText = (Convert.ToDecimal(view.GetGroupSummaryValue(e.RowHandle, CType (view.GroupSummary( "UnitPrice" ), GridGroupSummaryItem))) * Convert.ToDecimal(view.GetGroupSummaryValue(e.RowHandle, CType (view.GroupSummary( "UnitsInStock" ), GridGroupSummaryItem)))).ToString()
43
+ End If
44
+ End Sub
47
45
48
- Private Sub gridView1_CustomUnboundColumnData( ByVal sender As Object , ByVal e As CustomColumnDataEventArgs) Handles gridView1.CustomUnboundColumnData
49
- Dim view As GridView = DirectCast (sender, GridView)
50
- If e.Column Is colPrice Then
51
- If e.IsGetData Then
52
- e.Value = Convert.ToDecimal(view.GetListSourceRowCellValue(e.ListSourceRowIndex, colUnitPrice)) * Convert.ToInt32(view.GetListSourceRowCellValue(e.ListSourceRowIndex, colUnitsInStock))
53
- End If
54
- End If
55
- End Sub
56
- End Class
57
- End Namespace
46
+ Private Sub gridView1_CustomUnboundColumnData( ByVal sender As Object , ByVal e As CustomColumnDataEventArgs) Handles gridView1.CustomUnboundColumnData
47
+ Dim view As GridView = CType (sender, GridView)
48
+ If e.Column Is colPrice Then
49
+ If e.IsGetData Then e.Value = Convert.ToDecimal(view.GetListSourceRowCellValue(e.ListSourceRowIndex, colUnitPrice)) * Convert.ToInt32(view.GetListSourceRowCellValue(e.ListSourceRowIndex, colUnitsInStock))
50
+ End If
51
+ End Sub
52
+ End Class
53
+ End Namespace
0 commit comments