Question: So I was trying my hands on making a dialog box appear when the user exit the app and it will ask the question Are you sure you want to exit? The app exit but it doesn't show the dialog box.

Here is my code 

```
public void exit(View view) {

        //  showDialog(ALERT_DIALOG1);
            final AlertDialog.Builder builder = new AlertDialog.Builder(Register.this);
            builder.setCancelable(false);
            builder.setMessage("Are you sure you want to quit");
            builder.setPositiveButton("Yes", null);   
    }             
            public void onClick(DialogInterface dialog, int id) {
                    Register.this.finish();
//                  builder.show();

 }
           };

```

Answer: 
Yes, no problem.

As long as the owner of your DBGrid is not one of those tabsheets, but is higher up in the owning chain. Because otherwise, [the destruction of tabsheet A could lead to the destruction of your DBGrid on tabsheet B](https://stackoverflow.com/a/6461820/757830).
If you are using a TClientDataset, you can do something even better: have one grid on each tab and use clones (method CloneCursor) to change your index.
At that point, your DBGrids won't all point to the same dataset but each one to its own, where you set the IndexName (or fields, according to what you are doing).

This will be easier to maintain (each DBGrid does not mess with the others, if you need more just add DBGrids) and extensible (if you need more indexes you just create more clones).

The main drawback is that if you add a field, it has to go into all clones, which can be a problem if the application is evolving.

Another (completely different) option is to look at CodeCentral - John Kaster uploaded a DBGrid which lets you order by title. This was a *long* time ago, but it should still be there. It only works with Client datasets though.
You could, however, change that and add your own datasets where needed,I think it comes with source code. 
Hope it helps.