Click here to Skip to main content
15,887,337 members
Home / Discussions / C#
   

C#

 
GeneralRe: Prevent my process from being killed. Pin
syntax^8427-Apr-06 4:58
syntax^8427-Apr-06 4:58 
QuestionDatabinding not working...? Pin
mikker_12327-Apr-06 2:58
mikker_12327-Apr-06 2:58 
AnswerRe: Databinding not working...? Pin
Josh Smith27-Apr-06 3:53
Josh Smith27-Apr-06 3:53 
GeneralRe: Databinding not working...? Pin
mikker_12327-Apr-06 5:16
mikker_12327-Apr-06 5:16 
GeneralRe: Databinding not working...? Pin
Josh Smith27-Apr-06 7:09
Josh Smith27-Apr-06 7:09 
GeneralRe: Databinding not working...? Pin
mikker_12327-Apr-06 7:33
mikker_12327-Apr-06 7:33 
QuestionDATA GRID Pin
MilindKumar27-Apr-06 2:20
MilindKumar27-Apr-06 2:20 
AnswerRe: DATA GRID Pin
Josh Smith27-Apr-06 4:25
Josh Smith27-Apr-06 4:25 
You can accomplish this by using the following technique:

enum YesNo
{
	Y,
	N
}
private void Form1_Load(object sender, System.EventArgs e)
{
	DataTable tbl = new DataTable("testTable");

	// The "bit" column would come from the database, the "Y/N" column
	// is added in code.
	tbl.Columns.Add( "bit", typeof(bool) );
	tbl.Columns.Add( "Y/N", typeof(YesNo) );

	// Add a YesNo value for the boolean value in each row.
	tbl.Rows.Add( new object[] { true,  YesNo.Y } );
	tbl.Rows.Add( new object[] { false, YesNo.N } );

	this.dataGrid1.DataSource = tbl;

	tbl.RowChanged += new DataRowChangeEventHandler(tbl_RowChanged);

	DataGridTableStyle style = new DataGridTableStyle();
	style.MappingName = "testTable";
	this.dataGrid1.TableStyles.Add( style );
	style.GridColumnStyles.Remove( style.GridColumnStyles["bit"] );
}

private void tbl_RowChanged(object sender, DataRowChangeEventArgs e)
{
	if( e.Action == DataRowAction.Change )
		e.Row["bit"] = ((YesNo)e.Row["Y/N"]) == YesNo.Y;
}

Using the YesNo enum makes the grid automatically validate the text entered by the user, which it would not do if the column were a string datatype.

Josh
QuestionMemoryOutException Pin
agmb27-Apr-06 2:18
agmb27-Apr-06 2:18 
AnswerRe: MemoryOutException Pin
Ed.Poore27-Apr-06 3:39
Ed.Poore27-Apr-06 3:39 
AnswerRe: MemoryOutException Pin
V.27-Apr-06 4:13
professionalV.27-Apr-06 4:13 
AnswerRe: MemoryOutException Pin
Guffa27-Apr-06 7:12
Guffa27-Apr-06 7:12 
Questiontwo columns as source for checkedlistbox.DisplayMember ? Pin
livez27-Apr-06 1:29
livez27-Apr-06 1:29 
AnswerRe: two columns as source for checkedlistbox.DisplayMember ? Pin
Ed.Poore27-Apr-06 3:25
Ed.Poore27-Apr-06 3:25 
QuestionControlBox Close Button Pin
paas27-Apr-06 1:01
paas27-Apr-06 1:01 
AnswerRe: ControlBox Close Button Pin
Shajeel27-Apr-06 1:58
Shajeel27-Apr-06 1:58 
GeneralRe: ControlBox Close Button Pin
paas27-Apr-06 4:27
paas27-Apr-06 4:27 
AnswerRe: ControlBox Close Button Pin
Shajeel27-Apr-06 20:47
Shajeel27-Apr-06 20:47 
QuestionComboBox problem after MessageBox displayed Pin
joaoafonso27-Apr-06 0:23
joaoafonso27-Apr-06 0:23 
AnswerRe: ComboBox problem after MessageBox displayed Pin
Ed.Poore27-Apr-06 1:41
Ed.Poore27-Apr-06 1:41 
GeneralRe: ComboBox problem after MessageBox displayed Pin
joaoafonso27-Apr-06 2:00
joaoafonso27-Apr-06 2:00 
GeneralRe: ComboBox problem after MessageBox displayed Pin
Ed.Poore27-Apr-06 3:16
Ed.Poore27-Apr-06 3:16 
GeneralRe: ComboBox problem after MessageBox displayed Pin
joaoafonso27-Apr-06 6:00
joaoafonso27-Apr-06 6:00 
GeneralRe: ComboBox problem after MessageBox displayed Pin
Ed.Poore27-Apr-06 6:02
Ed.Poore27-Apr-06 6:02 
QuestionHow can i use a masked textbox column in a datagridview for date format Pin
Lee ju26-Apr-06 23:57
Lee ju26-Apr-06 23:57 

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.