how to point the cursor in specific cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everybody,
im working in infragistics ultragrid.
Can any one know how to get the cursor in to active cell .
i need to check the empty field before leaving cell.
if its empty then cursor should be forced to come into the empty field.
ive tried in beforedeactivecell event but the cursor is not coming to the
empty field when i changed the cursor to another cell.


below is my code
***
//function returns bool if cell is empty
chekemfield =checkemptyfield();

if(chekemfield ==true)
{
MessageBox.Show("Field must be
entered","V-1550",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error);


ultraGrid1.ActiveRow=ultraGrid1.Rows[actrowinx];
Infragistics.Win.UltraWinGrid.UltraGridCell acell;
acell = ultraGrid1.ActiveRow.Cells["INSULATION_DUTY"];
ultraGrid1.ActiveCell = acell;
ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);

//function

public bool checkemptyfield()
{
string duty=ultraGrid1.ActiveRow.Cells["INSULATION_DUTY"].Value.ToString();
string
material=ultraGrid1.ActiveRow.Cells["INSULATION_MATERIAL"].Value.ToString();
if(duty==string.Empty || material==string.Empty)
{

chekemfield=true;
return chekemfield;




}
else
{
chekemfield=false;
return chekemfield;
}

}


****
can anyone help me
 
Hello,

Try the BeforeExitEditMode event to validate the contents of the cell.


private void ultraGrid1_BeforeExitEditMode(object sender,
Infragistics.Win.UltraWinGrid.BeforeExitEditModeEventArgs e)
{
//...make sure the parent form is not disposing otherwise
//the MessageBox call will allow the process to "live on"
//after the form has disposed and dissapeared from the
//user's view.
if(!Disposing)
{
//...get the cell the user is editing...
Infragistics.Win.UltraWinGrid.UltraGridCell theCell =
((Infragistics.Win.UltraWinGrid.UltraGrid)sender).ActiveCell;

if(theCell.Column.Key == "MyColumn")
{
//perform some validation...
if(theCell.Text.Length == 0)
{
//cancel the "exit edit mode" event.
e.Cancel = true;

//alert the end user with a validation error
MessageBox.Show("Error Message", "Error Caption",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

Regards,
GM
http://nonspect.com
 
Back
Top