Click here to Skip to main content
15,564,500 members
Home / Discussions / C#
   

C#

 
GeneralRe: Something basic Pin
carbon_golem29-Apr-08 8:28
carbon_golem29-Apr-08 8:28 
GeneralRe: Something basic Pin
PIEBALDconsult29-Apr-08 13:11
professionalPIEBALDconsult29-Apr-08 13:11 
GeneralRe: Something basic Pin
Spykraft29-Apr-08 8:38
Spykraft29-Apr-08 8:38 
GeneralRe: Something basic Pin
carbon_golem29-Apr-08 9:06
carbon_golem29-Apr-08 9:06 
GeneralRe: Something basic Pin
Spykraft29-Apr-08 13:11
Spykraft29-Apr-08 13:11 
GeneralRe: Something basic Pin
carbon_golem29-Apr-08 17:59
carbon_golem29-Apr-08 17:59 
GeneralRe: Something basic Pin
PIEBALDconsult29-Apr-08 10:31
professionalPIEBALDconsult29-Apr-08 10:31 
GeneralDatagridview and keyenter Pin
Canann29-Apr-08 5:43
Canann29-Apr-08 5:43 
I have a form with a datagridview and the following class to handle the data keypress.
What code is missing to use the class.
I do not want to put this as a control.

I am new at this so anyhelp would be appreciated.

namespace WindowsApplication1
{

public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
DataGridViewTextBoxEditingControl dText = (DataGridViewTextBoxEditingControl)e.Control;
dText.KeyPress += new KeyPressEventHandler(/////);
}




}//end form class

//********************************************************************
#region DataGridViewControlClass

public class DataGridViewEnter : DataGridView
{


protected override bool ProcessDialogKey(Keys keyData)
{
Keys key = (keyData & Keys.KeyCode);
if (key == Keys.Enter)
{
return this.ProcessRightKey(keyData);
}
return base.ProcessDialogKey(keyData);
}

public new bool ProcessRightKey(Keys keyData)
{
int DGVfirstcolumn = 0;//First column shown
int DGVlastcolum = 5;//Last Column shown

Keys key = (keyData & Keys.KeyCode);
if (key == Keys.Enter)
{

//works on the current line
if ((base.CurrentCell.ColumnIndex == (DGVlastcolum)) && (base.CurrentCell.RowIndex == (base.RowCount - 1)))
{
try
{
((BindingSource)base.DataSource).EndEdit();
((BindingSource)base.DataSource).AddNew();
}
catch
{ } // do nothing
base.CurrentCell = base.Rows[base.RowCount - 1].Cells[DGVfirstcolumn];
return true;
}
//add a new line
if ((base.CurrentCell.ColumnIndex == (DGVlastcolum)) && (base.CurrentCell.RowIndex != base.NewRowIndex))
{
base.CurrentCell = base.Rows[base.CurrentCell.RowIndex + 1].Cells[DGVfirstcolumn];
return true;
}
return base.ProcessRightKey(keyData);
}
return base.ProcessRightKey(keyData);
}

protected override bool ProcessDataGridViewKey(KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
return this.ProcessRightKey(e.KeyData);
}
return base.ProcessDataGridViewKey(e);
}
}
#endregion



}//end namespace
QuestionRe: Datagridview and keyenter Pin
Canann30-Apr-08 3:51
Canann30-Apr-08 3:51 
QuestionHow to generate Typed DataSet with CodeDom ? Pin
hdv21229-Apr-08 4:03
hdv21229-Apr-08 4:03 
Generalanti-pattern in GC Pin
George_George29-Apr-08 3:59
George_George29-Apr-08 3:59 
GeneralRe: anti-pattern in GC Pin
Colin Angus Mackay29-Apr-08 5:03
Colin Angus Mackay29-Apr-08 5:03 
GeneralRe: anti-pattern in GC Pin
George_George29-Apr-08 5:26
George_George29-Apr-08 5:26 
GeneralRe: anti-pattern in GC Pin
led mike29-Apr-08 5:53
led mike29-Apr-08 5:53 
GeneralRe: anti-pattern in GC Pin
George_George29-Apr-08 5:59
George_George29-Apr-08 5:59 
GeneralRe: anti-pattern in GC Pin
led mike29-Apr-08 6:40
led mike29-Apr-08 6:40 
GeneralRe: anti-pattern in GC Pin
George_George29-Apr-08 21:41
George_George29-Apr-08 21:41 
GeneralRe: anti-pattern in GC Pin
led mike30-Apr-08 5:50
led mike30-Apr-08 5:50 
GeneralRe: anti-pattern in GC Pin
George_George30-Apr-08 23:06
George_George30-Apr-08 23:06 
GeneralRe: anti-pattern in GC Pin
led mike1-May-08 7:18
led mike1-May-08 7:18 
GeneralRe: anti-pattern in GC Pin
George_George1-May-08 22:47
George_George1-May-08 22:47 
Generalinserting string into string Pin
stephan_00729-Apr-08 3:59
stephan_00729-Apr-08 3:59 
GeneralRe: inserting string into string Pin
carbon_golem29-Apr-08 4:58
carbon_golem29-Apr-08 4:58 
GeneralRe: inserting string into string Pin
carbon_golem29-Apr-08 4:59
carbon_golem29-Apr-08 4:59 
QuestionC# TextBox with forward slash Pin
WaleedH29-Apr-08 3:52
WaleedH29-Apr-08 3:52 

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.