Index: pgadmin/include/frm/frmEditGrid.h
===================================================================
--- pgadmin/include/frm/frmEditGrid.h	(revision 7027)
+++ pgadmin/include/frm/frmEditGrid.h	(working copy)
@@ -122,6 +122,7 @@
     int GetNumberStoredRows();
     int GetNumberCols();
     wxString GetColLabelValue(int col);
+    wxString GetColLabelValueUnformatted(int col);
     wxString GetRowLabelValue(int row);
     wxGridCellAttr* GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind);
 
@@ -214,9 +215,13 @@
     void OnEditorHidden(wxGridEvent& event);
     void OnKey(wxKeyEvent& event);
     void OnCopy(wxCommandEvent& event);
+    void OnIncludeFilter(wxCommandEvent& event);
+    void OnExcludeFilter(wxCommandEvent& event);
+    void OnRemoveFilters(wxCommandEvent& event);
     void OnPaste(wxCommandEvent& event);
     void OnLabelDoubleClick(wxGridEvent& event);
     void OnLabelRightClick(wxGridEvent& event);
+    void OnCellRightClick(wxGridEvent& event);
     void Abort();
     void OnToggleScratchPad(wxCommandEvent& event);
     void OnToggleLimitBar(wxCommandEvent& event);
Index: pgadmin/include/frm/menu.h
===================================================================
--- pgadmin/include/frm/menu.h	(revision 7027)
+++ pgadmin/include/frm/menu.h	(working copy)
@@ -46,6 +46,9 @@
     MNU_OPTIONS,
     MNU_CUT,
     MNU_COPY,
+    MNU_INCLUDEFILTER,
+    MNU_EXCLUDEFILTER,
+    MNU_REMOVEFILTERS,
     MNU_PASTE,
     MNU_CLEAR,
     MNU_FIND,
Index: pgadmin/frm/frmEditGrid.cpp
===================================================================
--- pgadmin/frm/frmEditGrid.cpp	(revision 7027)
+++ pgadmin/frm/frmEditGrid.cpp	(working copy)
@@ -59,6 +59,9 @@
     EVT_MENU(MNU_REFRESH,       frmEditGrid::OnRefresh)
     EVT_MENU(MNU_DELETE,        frmEditGrid::OnDelete)
     EVT_MENU(MNU_SAVE,          frmEditGrid::OnSave)
+    EVT_MENU(MNU_INCLUDEFILTER, frmEditGrid::OnIncludeFilter)
+    EVT_MENU(MNU_EXCLUDEFILTER, frmEditGrid::OnExcludeFilter)
+    EVT_MENU(MNU_REMOVEFILTERS, frmEditGrid::OnRemoveFilters)
     EVT_MENU(MNU_UNDO,          frmEditGrid::OnUndo)
     EVT_MENU(MNU_OPTIONS,       frmEditGrid::OnOptions)
     EVT_MENU(MNU_HELP,          frmEditGrid::OnHelp)
@@ -76,6 +79,7 @@
     EVT_GRID_SELECT_CELL(       frmEditGrid::OnCellChange)
     EVT_GRID_EDITOR_SHOWN(      frmEditGrid::OnEditorShown)
     EVT_GRID_EDITOR_HIDDEN(     frmEditGrid::OnEditorHidden)
+    EVT_GRID_CELL_RIGHT_CLICK(  frmEditGrid::OnCellRightClick)
     EVT_GRID_LABEL_RIGHT_CLICK( frmEditGrid::OnLabelRightClick)
     EVT_AUI_PANE_BUTTON(        frmEditGrid::OnAuiUpdate)
 END_EVENT_TABLE()
@@ -388,6 +392,24 @@
 }
 
 
+void frmEditGrid::OnCellRightClick(wxGridEvent& event)
+{
+	wxMenu *xmenu = new wxMenu();
+	
+	wxArrayInt rows=sqlGrid->GetSelectedRows();
+	
+	xmenu->Append(MNU_INCLUDEFILTER, _("Filter By &Selection"),_("Display only those rows that have this value in this column."));
+	xmenu->Append(MNU_EXCLUDEFILTER, _("Filter E&xcluding Selection"),_("Display only those rows that do not have this value in this column."));
+	xmenu->Append(MNU_REMOVEFILTERS, _("&Remove Filter/Sort"),_("Remove all filters on this table"));
+	
+	xmenu->Enable(MNU_INCLUDEFILTER, true);
+	xmenu->Enable(MNU_EXCLUDEFILTER, true);
+	xmenu->Enable(MNU_REMOVEFILTERS, true);
+	
+	sqlGrid->PopupMenu(xmenu);
+}
+
+
 void frmEditGrid::OnCellChange(wxGridEvent& event)
 {
     sqlTable *table=sqlGrid->GetTable();
@@ -416,6 +438,113 @@
 }
 
 
+void frmEditGrid::OnIncludeFilter(wxCommandEvent &event)
+{
+	int curcol=sqlGrid->GetGridCursorCol();
+	int currow=sqlGrid->GetGridCursorRow();
+	
+	sqlTable *table=sqlGrid->GetTable();
+	wxString column_label = table->GetColLabelValueUnformatted(curcol);
+	wxString new_filter_string;
+	
+	size_t old_filter_string_length = GetFilter().Trim().Len();
+	
+	if (old_filter_string_length > 0) {
+		new_filter_string = GetFilter().Trim() + wxString::Format(_(" AND "));
+	
+//	skipping this else since wxString is initialized as an empty string ?
+//	} else { 
+//		new_filter_string = wxString::Format(_(""));
+	
+	}
+		
+	if (table->IsColText(curcol)) {
+		
+		if (sqlGrid->GetCellValue(currow, curcol).IsNull()) {
+			new_filter_string += column_label + wxString::Format(_(" IS NULL "));
+		} else {
+			
+			// Only if someone could help me put a case for an 'empty string' here ?
+			// :( this part isn't working as yet
+			
+			//if ((int)sqlGrid->GetCellValue(currow, curcol).Length() == 0) {
+				//new_filter_string += column_label + wxString::Format(_(" = ''"));
+			//} else {
+				new_filter_string += column_label + wxString::Format(_(" = '")) + sqlGrid->GetCellValue(currow, curcol) + wxString::Format(_("' "));
+			//}
+		}
+	} else {
+		
+		if (sqlGrid->GetCellValue(currow, curcol).IsNull()) {
+			new_filter_string += column_label + wxString::Format(_(" IS NULL "));
+		} else {
+			new_filter_string += column_label + wxString::Format(_(" = ")) + sqlGrid->GetCellValue(currow, curcol);
+		}
+	}
+	
+	SetFilter(new_filter_string);
+	
+	Go();
+}
+
+
+void frmEditGrid::OnExcludeFilter(wxCommandEvent &event)
+{
+	int curcol=sqlGrid->GetGridCursorCol();
+	int currow=sqlGrid->GetGridCursorRow();
+	
+	sqlTable *table=sqlGrid->GetTable();
+	wxString column_label = table->GetColLabelValueUnformatted(curcol);
+	wxString new_filter_string;
+	
+	size_t old_filter_string_length = GetFilter().Trim().Len();
+	
+	if (old_filter_string_length > 0) {
+		new_filter_string = GetFilter().Trim() + wxString::Format(_(" AND "));
+	
+//	skipping this else since wxString is initialized as an empty string.
+//	} else { 
+//		new_filter_string = wxString::Format(_(""));
+	
+	}
+	
+	if (table->IsColText(curcol)) {
+		if (sqlGrid->GetCellValue(currow, curcol).IsNull()) {
+			new_filter_string += column_label + wxString::Format(_(" IS NOT NULL "));
+		} else {
+			
+			// Only if someone could help me put a case for an 'empty string' here ?
+			// :( this part isn't working as yet
+			
+			//if ((int)sqlGrid->GetCellValue(currow, curcol).Length() == 0) {
+				//new_filter_string += column_label + wxString::Format(_(" <> '' ")) ;
+			//} else {
+				new_filter_string += column_label + wxString::Format(_(" <> '")) + sqlGrid->GetCellValue(currow, curcol) + wxString::Format(_("' "));
+			//}
+		}
+	} else {
+		
+		if (sqlGrid->GetCellValue(currow, curcol).IsNull()) {
+			new_filter_string += column_label + wxString::Format(_(" IS NOT NULL ")) ;
+		} else {
+			new_filter_string += column_label + wxString::Format(_(" <> ")) + sqlGrid->GetCellValue(currow, curcol);
+		}
+	}
+
+	SetFilter(new_filter_string);
+	
+	Go();
+}
+
+
+void frmEditGrid::OnRemoveFilters(wxCommandEvent &event)
+{
+	SetFilter(wxString::Format(_("")));
+	
+	Go();
+}
+
+
 void frmEditGrid::OnCopy(wxCommandEvent &ev)
 {
     wxWindow *wnd=FindFocus();
@@ -1994,6 +2123,12 @@
 }
 
 
+wxString sqlTable::GetColLabelValueUnformatted(int col)
+{
+    return columns[col].name;
+}
+
+
 wxString sqlTable::GetRowLabelValue(int row)
 {
     wxString label;
