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

Visual Basic

 
GeneralRe: Request (Reference to) other page Pin
Dave Kreskowiak23-Mar-04 14:14
mveDave Kreskowiak23-Mar-04 14:14 
GeneralRe: Request (Reference to) other page Pin
Michael Flanakin23-Mar-04 14:22
Michael Flanakin23-Mar-04 14:22 
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 
Sorry it is DataGridBoolColumn class.
An example is available in MSDN. Just I m giving it below..

using System;
using System.Data;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

public class MyForm : Form
{
private DataTable myTable;
private DataGrid myGrid = new DataGrid();

public MyForm() : base()
{
try
{
InitializeComponent();

myTable = new DataTable("NamesTable");
myTable.Columns.Add(new DataColumn("Name"));
DataColumn column = new DataColumn
("id", typeof(System.Int32));
myTable.Columns.Add(column);
myTable.Columns.Add(new
DataColumn("calculatedField", typeof(bool)));
DataSet namesDataSet = new DataSet();
namesDataSet.Tables.Add(myTable);
myGrid.SetDataBinding(namesDataSet, "NamesTable");

AddTableStyle();
AddData();
}
catch (System.Exception exc)
{
Console.WriteLine(exc.ToString());
}
}


private void grid_Enter(object sender, EventArgs e)
{
myGrid.CurrentCell = new DataGridCell(2,2);
}

private void AddTableStyle()
{
// Map a new TableStyle to the DataTable. Then
// add DataGridColumnStyle objects to the collection
// of column styles with appropriate mappings.
DataGridTableStyle dgt = new DataGridTableStyle();
dgt.MappingName = "NamesTable";

DataGridTextBoxColumn dgtbc = 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);

DataGridBoolColumn db =
new DataGridBoolColumn();
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";
}

private void 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.
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();
}

private void InitializeComponent()
{
this.Size = new Size(500, 500);
myGrid.Size = new Size(350, 250);
myGrid.TabStop = true;
myGrid.TabIndex = 1;

this.StartPosition = FormStartPosition.CenterScreen;
this.Controls.Add(myGrid);
}
[STAThread]
public static void Main()
{
MyForm myGridForm = new MyForm();
myGridForm.ShowDialog();
}
}
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 
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 

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.