Index: pgadmin/dlg/dlgIndex.cpp
===================================================================
--- pgadmin/dlg/dlgIndex.cpp	(revision 7873)
+++ pgadmin/dlg/dlgIndex.cpp	(working copy)
@@ -158,6 +158,7 @@
 #ifdef __WXMAC__
     EVT_SIZE(                                       dlgIndex::OnChangeSize)
 #endif
+    EVT_COMBOBOX(XRCID("cbType"),                   dlgIndex::OnSelectType)
 END_EVENT_TABLE();
 
         
@@ -197,7 +198,57 @@
     }
 }
 
+void dlgIndex::OnSelectType(wxCommandEvent &ev)
+{
+    // The column options available change depending on the
+    // index type. We need to clear the column list, and 
+    // setup some of the other controls accordingly.
 
+    wxString newType = cbType->GetValue();
+    bool changingDefault = false;
+
+    // Detect if we're changing between default and btree (which are the same) to
+    // avoid annoying the user needlessly.
+    if ((m_previousType == wxEmptyString && cbType->GetValue() == wxT("btree")) ||
+        (m_previousType == wxT("btree") && cbType->GetValue() == wxEmptyString))
+        changingDefault = true;
+
+    if (lstColumns->GetItemCount() > 0 && !changingDefault)
+    {
+        if (wxMessageBox(_("Changing the index type will cause the column list to be cleared. Do you wish to continue?"), _("Change index type?"), wxYES_NO) == wxNO)
+        {
+            cbType->SetValue(m_previousType);
+            return;
+        }
+
+        // Move all the columns back to the combo
+        for (int pos = lstColumns->GetItemCount(); pos > 0; pos--)
+        {
+            wxString colName = lstColumns->GetItemText(pos - 1);
+
+            lstColumns->DeleteItem(pos - 1);
+            cbColumns->Append(colName);
+        }
+    }
+
+    if (newType == wxT("btree") || newType == wxEmptyString)
+    {
+        chkDesc->Enable(true);
+        rdbNullsFirst->Enable(true);
+        rdbNullsLast->Enable(true);
+    }
+    else
+    {
+        chkDesc->Enable(false);
+        rdbNullsFirst->Enable(false);
+        rdbNullsLast->Enable(false);
+    }
+
+    // Make a note of the type so we can compare if it changes again.
+    m_previousType = cbType->GetValue();
+}
+
+
 wxString dlgIndex::GetColumns()
 {
     wxString sql;
@@ -350,21 +401,36 @@
         {
             if (chkDesc->GetValue())
             {
-                lstColumns->SetItem(colIndex, 1, wxT("DESC"));
+                if (chkDesc->IsEnabled())
+                    lstColumns->SetItem(colIndex, 1, wxT("DESC"));
 
+
                 if (rdbNullsLast->GetValue())
-                    lstColumns->SetItem(colIndex, 2, wxT("LAST"));
+                {
+                    if (rdbNullsLast->IsEnabled())
+                        lstColumns->SetItem(colIndex, 2, wxT("LAST"));
+                }
                 else
-                    lstColumns->SetItem(colIndex, 2, wxT("FIRST"));
+                {
+                    if (rdbNullsLast->IsEnabled())
+                        lstColumns->SetItem(colIndex, 2, wxT("FIRST"));
+                }
             }
             else
             {
-                lstColumns->SetItem(colIndex, 1, wxT("ASC"));
+                if (chkDesc->IsEnabled())
+                    lstColumns->SetItem(colIndex, 1, wxT("ASC"));
 
                 if (rdbNullsFirst->GetValue())
-                    lstColumns->SetItem(colIndex, 2, wxT("FIRST"));
+                {
+                    if (rdbNullsFirst->IsEnabled())
+                        lstColumns->SetItem(colIndex, 2, wxT("FIRST"));
+                }
                 else
-                    lstColumns->SetItem(colIndex, 2, wxT("LAST"));
+                {
+                    if (rdbNullsLast->IsEnabled())
+                        lstColumns->SetItem(colIndex, 2, wxT("LAST"));
+                }
             }
         }
 
Index: pgadmin/include/dlg/dlgIndex.h
===================================================================
--- pgadmin/include/dlg/dlgIndex.h	(revision 7873)
+++ pgadmin/include/dlg/dlgIndex.h	(working copy)
@@ -59,10 +59,13 @@
     void OnChangeSize(wxSizeEvent &ev);
 #endif
 
+    void OnSelectType(wxCommandEvent &ev);
     void OnDescChange(wxCommandEvent &ev);
     void OnAddCol(wxCommandEvent &ev);
     void OnRemoveCol(wxCommandEvent &ev);
 
+    wxString m_previousType;
+
     DECLARE_EVENT_TABLE()
 };
 
