Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
390
Tabrepeat functionality
posted

I want my Ultragrid to add a new row when i tab while being in the last cell of the last row with my cursor. Now i know that Ultragrid supports this by default with TabRepeat. Unfortunately my grid can't add rows because i use a List as a Datasource (Nhibernate). To still allow adding of rows i made a function myself that adds a new record. Now i want to mimic the functionality of TabRepeat using this function.

I tried to search for the TabRepeat event but i can't find it so i started looking into the KeyPressed event. I managed to check if the tab key is pressed using the following check:

if (e.KeyChar == '\t')

However i have no idea how to check if the ActiveCell is the last cell. Any help will be appriciated.

Parents
  • 390
    posted

    Thanks for the reply guys. This is how the event is looking now:

            private void dgvOverview_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (e.KeyChar == '\t' && dgvOverview.ActiveCell.Column.Header.VisiblePosition == 3 && dgvOverview.ActiveRow.Index == dgvOverview.Rows.Count - 1)
                {
                    MessageBox.Show("Execute new row function");
                }
            }

    This event triggers just fine when i press tab in the last column at the last row. However it also triggers when i press tab to go from the 2nd column to the last column at the last row. Any idea's how i can get the event to trigger only when i press tab while begin in the last column?

    Btw nsmith555: I tried using dgvOverview.ActiveCell.Column.Tag.ToString() == "Status" but somehow it gives me a nullpointer exception when i enter the last column. I don't understand why because i do have an activecell since the code above works just fine.

Reply Children