Current cell cannot be set to an invisible cell-VBForums
Results 1 to 5 of 5

Thread: Current cell cannot be set to an invisible cell

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    166

    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

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    87,350

    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.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    166

    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..

  4. #4
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    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?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    166

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.