Saturday, December 5, 2009

Apophysis

Nice site for this wonderful program
http://apophysisrevealed.com/

C++/CLI Programming

http://www.functionx.com/cppcli/index.htm

FAQ C++/CLI

http://dotnet.developpez.com/faq/cppcli/?page=sommaire#sommaire

Unsafe Code and Pointers (C# Programming Guide)

http://msdn.microsoft.com/en-us/library/t2yzs44b%28VS.80%29.aspx

Create and access a pointer array

http://en.csharp-online.net/Create_and_access_a_pointer_array

Pointers in C#

I need to parse large amount of data in Excel Sheet.
I trying to use pointers for performance issues
Here is how to define pointers in C#
http://msdn.microsoft.com/en-us/library/f58wzh21%28VS.71%29.aspx

Friday, December 4, 2009

C# - DatagridView

I was in search of editing cell programmatically.
Here is a simple attempt


using System.Collections.Generic;
using System.Windows.Forms;

namespace testGridView
{
public partial class Form1 : Form
{
List cars;

int currentValue;

public Form1()
{
InitializeComponent();
InitializeCarsCollection();
SetLayoutGrid();
this.dataGridView1.DataSource = cars;
}

private void SetLayoutGrid()
{
this.dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1_CellClick);
this.dataGridView1.CellEndEdit += new DataGridViewCellEventHandler(dataGridView1_CellEndEdit);
this.dataGridView1.Dock = DockStyle.Fill;
this.dataGridView1.AutoGenerateColumns = true;
this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
}

void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
int editedValue = (int)this.dataGridView1[e.ColumnIndex, e.RowIndex].Value;

if (editedValue != this.currentValue)
{
System.Windows.Forms.MessageBox.Show(this.dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString());
}
}

void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{


if (e.ColumnIndex == 2)
{
this.currentValue = (int)this.dataGridView1[e.ColumnIndex, e.RowIndex].Value;
this.dataGridView1.BeginEdit(true);
}
}

private void InitializeCarsCollection()
{
cars = new List();
cars.Add(new Car { Marque = "Renault", Couleur = "rouge", Cylindree = 6 });
cars.Add(new Car { Marque = "Citroen", Couleur = "bleu", Cylindree = 4 });
cars.Add(new Car { Marque = "Peugeot", Couleur = "vert", Cylindree = 8 });
cars.Add(new Car { Marque = "BMW", Couleur = "jaune", Cylindree = 16 });
}
}
}