Click here to Skip to main content
16,006,355 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralHelp Needed Pin
hmssws23-Mar-04 2:37
hmssws23-Mar-04 2:37 
GeneralRe: Help Needed Pin
Dave Kreskowiak23-Mar-04 4:10
mveDave Kreskowiak23-Mar-04 4:10 
Generaldisplay checkbox in columns of datagrid Pin
Chrissy Callen23-Mar-04 0:30
Chrissy Callen23-Mar-04 0:30 
GeneralRe: display checkbox in columns of datagrid Pin
Syed Abdul Khader23-Mar-04 2:09
Syed Abdul Khader23-Mar-04 2:09 
GeneralRe: display checkbox in columns of datagrid Pin
Chrissy Callen23-Mar-04 2:13
Chrissy Callen23-Mar-04 2:13 
GeneralRe: display checkbox in columns of datagrid Pin
Syed Abdul Khader23-Mar-04 2:19
Syed Abdul Khader23-Mar-04 2:19 
GeneralRe: display checkbox in columns of datagrid Pin
Chrissy Callen23-Mar-04 2:57
Chrissy Callen23-Mar-04 2:57 
GeneralRe: display checkbox in columns of datagrid Pin
Syed Abdul Khader23-Mar-04 3:04
Syed Abdul Khader23-Mar-04 3:04 
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Drawing
Imports System.ComponentModel

Public Class MyForm
Inherits System.Windows.Forms.Form
Private components As System.ComponentModel.Container
Private myTable As DataTable
Private myGrid As DataGrid = New DataGrid

Public Shared Sub Main()
Application.Run(New MyForm)
End Sub

Public Sub New()
Try
InitializeComponent()
myTable = New DataTable("NamesTable")
myTable.Columns.Add(New DataColumn("Name"))
Dim column As DataColumn = New DataColumn _
("id", GetType(System.Int32))
myTable.Columns.Add(column)
myTable.Columns.Add(New DataColumn _
("calculatedField", GetType(Boolean)))
Dim namesDataSet As DataSet = New DataSet("myDataSet")
namesDataSet.Tables.Add(myTable)
myGrid.SetDataBinding(namesDataSet, "NamesTable")
AddData()
AddTableStyle()

Catch exc As System.Exception
Console.WriteLine(exc.ToString)
End Try
End Sub

Private Sub AddTableStyle()
' Map a new TableStyle to the DataTable. Then
' add DataGridColumnStyle objects to the collection
' of column styles with appropriate mappings.
Dim dgt As DataGridTableStyle = New DataGridTableStyle
dgt.MappingName = "NamesTable"

Dim dgtbc As DataGridTextBoxColumn = _
New DataGridTextBoxColumn
dgtbc.MappingName = "Name"
dgtbc.HeaderText = "Name"
dgt.GridColumnStyles.Add(dgtbc)

dgtbc = New DataGridTextBoxColumn
dgtbc.MappingName = "id"
dgtbc.HeaderText = "id"
dgt.GridColumnStyles.Add(dgtbc)

Dim db As DataGridBoolColumnInherit = _
New DataGridBoolColumnInherit
db.HeaderText = "less than 1000 = blue"
db.Width = 150
db.MappingName = "calculatedField"
dgt.GridColumnStyles.Add(db)

myGrid.TableStyles.Add(dgt)

' This expression instructs the grid to change
' the color of the inherited DataGridBoolColumn
' according to the value of the id field. If it's
' less than 1000, the row is blue. Otherwise,
' the color is yellow.
'db.Expression = "id < 1000"
End Sub

Private Sub AddData()

' Add data with varying numbers for the id field.
' If the number is over 1000, the cell will paint
' yellow. Otherwise, it will be blue.
Dim dRow As DataRow

dRow = myTable.NewRow()
dRow("Name") = "name 1"
dRow("id") = 999
myTable.Rows.Add(dRow)

dRow = myTable.NewRow()
dRow("Name") = "name 2"
dRow("id") = 2300
myTable.Rows.Add(dRow)

dRow = myTable.NewRow()
dRow("Name") = "name 3"
dRow("id") = 120
myTable.Rows.Add(dRow)

dRow = myTable.NewRow()
dRow("Name") = "name 4"
dRow("id") = 4023
myTable.Rows.Add(dRow)

dRow = myTable.NewRow()
dRow("Name") = "name 5"
dRow("id") = 2345
myTable.Rows.Add(dRow)

myTable.AcceptChanges()
End Sub

Private Sub InitializeComponent()
Me.Size = New Size(500, 500)
myGrid.Size = New Size(350, 250)
myGrid.TabStop = True
myGrid.TabIndex = 1
Me.StartPosition = FormStartPosition.CenterScreen
Me.Controls.Add(myGrid)
End Sub

End Class
GeneralRe: display checkbox in columns of datagrid Pin
Chrissy Callen23-Mar-04 3:29
Chrissy Callen23-Mar-04 3:29 
GeneralRe: display checkbox in columns of datagrid Pin
roshanak23-Mar-04 22:06
roshanak23-Mar-04 22:06 
GeneralRe: display checkbox in columns of datagrid Pin
Chrissy Callen23-Mar-04 23:23
Chrissy Callen23-Mar-04 23:23 
GeneralPlease help me! _event handeling Pin
xstoneheartx22-Mar-04 23:37
xstoneheartx22-Mar-04 23:37 
GeneralRe: Please help me! _event handeling Pin
Dave Kreskowiak23-Mar-04 1:02
mveDave Kreskowiak23-Mar-04 1:02 
GeneralRe: Please help me! _event handeling Pin
xstoneheartx23-Mar-04 1:55
xstoneheartx23-Mar-04 1:55 
GeneralRe: Please help me! _event handeling Pin
Nadroj23-Mar-04 3:40
Nadroj23-Mar-04 3:40 
GeneralRe: Please help me! _event handeling Pin
xstoneheartx23-Mar-04 9:58
xstoneheartx23-Mar-04 9:58 
GeneralRe: Please help me! _event handeling Pin
Nadroj23-Mar-04 12:25
Nadroj23-Mar-04 12:25 
GeneralVisual Basic .NET 2003 Questions Pin
Kane~22-Mar-04 22:39
sussKane~22-Mar-04 22:39 
GeneralRe: Visual Basic .NET 2003 Questions Pin
Dave Kreskowiak23-Mar-04 1:27
mveDave Kreskowiak23-Mar-04 1:27 
GeneralRAS MprAdmin Problems Pin
MASOSi22-Mar-04 22:38
MASOSi22-Mar-04 22:38 
GeneralRe: RAS MprAdmin Problems Pin
MASOSi23-Mar-04 1:21
MASOSi23-Mar-04 1:21 
GeneralAccessing VB6 Constants Pin
Edbert P22-Mar-04 18:21
Edbert P22-Mar-04 18:21 
GeneralRe: Accessing VB6 Constants Pin
Dave Kreskowiak23-Mar-04 1:38
mveDave Kreskowiak23-Mar-04 1:38 
GeneralRe: Accessing VB6 Constants Pin
Edbert P23-Mar-04 11:02
Edbert P23-Mar-04 11:02 
GeneralRe: Accessing VB6 Constants Pin
Dave Kreskowiak23-Mar-04 11:28
mveDave Kreskowiak23-Mar-04 11:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.