-
Aug 3rd, 2008, 09:56 PM
#1
Thread Starter
Addicted Member
Current cell cannot be set to an invisible cell
"Current cell cannot be set to an invisible cell"
How can I handle this error? thanks
-
Aug 4th, 2008, 12:25 AM
#2
Re: Current cell cannot be set to an invisible cell
Don't set the current cell to an invisible cell.
If you want more information then how about you go first? You've spent no time and made no effort to provide a clear and full description of your issue, yet you'd like us to spend the time and make the effort to solve it for you. Doesn't really seem fair, does it?
Maybe you could consider what information we might need to have a hope of doing more than guess at what the issue might be. What control are you using? What code did you execute that threw that exception? Etc., etc.
-
Aug 4th, 2008, 03:18 AM
#3
Thread Starter
Addicted Member
Re: Current cell cannot be set to an invisible cell
Sorry for lack of information. My bad
Here's my code:
Code:
private void dataGridViewItemTransactions_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (e.RowIndex < 0 || e.ColumnIndex < 0)
{
return;
}
DataGridView dataGridView = (DataGridView)sender;
decimal value;
if (dataGridView.Columns["columnQuantity"].Index == e.ColumnIndex && decimal.TryParse(e.FormattedValue.ToString(), out value) == false)
{
dataGridView.Rows[e.RowIndex].Cells["columnQuantity"].ErrorText = "Please enter valid Quantity. \n Value entered is " + e.FormattedValue.ToString() + "\n Changes are canceled";
e.Cancel = false;
}
else
{
dataGridView.Rows[e.RowIndex].Cells["columnQuantity"].ErrorText = "";
e.Cancel = false;
}
}
private void dataGridViewItemTransactions_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
e.Cancel = true;
}
private void dataGridViewItemTransactions_CellValidated(object sender, DataGridViewCellEventArgs e)
{
if (dataGridViewItemTransactions.Columns[e.ColumnIndex].Name == "columnRemarks" | dataGridViewItemTransactions.NewRowIndex == e.RowIndex)
return;
if (dataGridViewItemTransactions.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == string.Empty)
{
if (dataGridViewItemTransactions.Columns[e.ColumnIndex].Name == "columnItemNameButton")
{
dataGridViewItemTransactions.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "Please press this button to select. ";
}
else
{
dataGridViewItemTransactions.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = UserMessages.FILL_CELL;
}
}
else
{
dataGridViewItemTransactions.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = string.Empty;
}
if (e.RowIndex < 0 || e.ColumnIndex < 0)
{
return;
}
if (dataGridViewItemTransactions.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == string.Empty)
{
return;
}
if (dataGridViewItemTransactions.Columns["columnQuantity"].Index == e.ColumnIndex)
{
DataGridViewCellStyle currentCellStyle;
currentCellStyle = new DataGridViewCellStyle();
if (Convert.ToDecimal(dataGridViewItemTransactions.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) > 0)
{
currentCellStyle.BackColor = Color.LightYellow;
}
else
{
currentCellStyle.BackColor = Color.White;
}
if (dataGridViewItemTransactions.Columns["columnQuantity"].Index == e.ColumnIndex)
{
dataGridViewItemTransactions.Rows[e.RowIndex].Cells["columnQuantity"].Style = currentCellStyle;
}
}
}
I'm getting an error when I input an invalid value (that is in the Quantity column in datagridview having a decimal data type) I break my code in data error event and the problem is in there. I 'm getting that error only in the first row, but after i input a valid one, the program runs fine.. i need your help guys, i don't know how to " work around this thing." thanks guys for patience..
-
Aug 4th, 2008, 02:41 PM
#4
Re: Current cell cannot be set to an invisible cell
Not sure I understand - you're saying you get an error if you input an invalid value. And things work fine when you input a valid value. If this is unexpected behavior, what are you trying to do with it? Do you want to just ignore the error?
-
Aug 4th, 2008, 06:59 PM
#5
Thread Starter
Addicted Member
Re: Current cell cannot be set to an invisible cell
based on my program.. i did some defensive programming for the user limits their input.. So my concern here is to validate all the user input and trap those invalid values. My validation routine works fine after I input the first row an invalid value. but in one scenario it fails, that is , when i input at the first time an invalid value saying that:""Current cell cannot be set to an invisible cell"" I don't expect that error.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|