Skip to content

Instantly share code, notes, and snippets.

View Zujaj's full-sized avatar

Zujaj Misbah Khan Zujaj

  • @TelicSolutionsInc
View GitHub Profile
@Zujaj
Zujaj / Person.cs
Last active October 12, 2020 06:29
Person Model C# Code
using System;
using System.Collections.Generic;
namespace DataGridViewAutoFilterDemo
{
public class Person
{
private readonly Random random = new Random();
public int Rank { get; set; }
@Zujaj
Zujaj / ShowAllLabel_Click.cs
Last active October 12, 2020 09:05
Code behind ShowAllLabel_Click
private void ShowAllLabel_Click(object sender, EventArgs e)
{
DataGridViewAutoFilterTextBoxColumn.RemoveFilter(dataGridView1);
}
@Zujaj
Zujaj / EnableGridFilter.cs
Last active October 12, 2020 10:21
Enable or Disable DataGridView AutoFiltering
/// <summary>
/// Enable filtering on grid columns by setting the value to true.
/// It's false by default.
/// </summary>
/// <param name="value"></param>
private void EnableGridFilter(bool value)
{
RankColumn.FilteringEnabled = value;
OccupationColumn.FilteringEnabled = value;
// Object of Person model
private Person personObject = new Person();
// List to hold person details
private List<Person> personList = new List<Person>();
@Zujaj
Zujaj / TestAppForm_Load.cs
Created October 12, 2020 10:04
Form Load Event of TestApp
private void TestAppForm_Load(object sender, EventArgs e)
{
// Invoke the method PopulateList using the person object
// Pass the personList as the parameter.
personObject.PopulateList(personList);
// Use morelinq ToDataTable extension for converting personList to DataTable.
// Assign the converted Datatable to BindingSource's DataSource.
personBindingSource.DataSource = personList.ToDataTable();
@Zujaj
Zujaj / DataGridView_DataBindingComplete.cs
Last active October 12, 2020 10:16
Demonstrates the DataGridView_DataBindingComplete
private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
string filterStatus = DataGridViewAutoFilterColumnHeaderCell.GetFilterStatus(dataGridView1);
if (string.IsNullOrEmpty(filterStatus))
{
ShowAllLabel.Visible = false;
FilterStatusLabel.Visible = false;
}
else
{
@Zujaj
Zujaj / DataGridView_KeyDown.cs
Last active October 12, 2020 10:25
Demonstrates KeyDown event of DataGridView
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt
&& (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up)
&& dataGridView1.CurrentCell != null
&& dataGridView1.CurrentCell.OwningColumn.HeaderCell is DataGridViewAutoFilterColumnHeaderCell filterCell)
{
filterCell.ShowDropDownList();
e.Handled = true;
}
@Zujaj
Zujaj / TestApp.cs
Last active October 12, 2020 10:32
Demonstrates the code for DataGridViewAutoFilter TestApp
using DataGridViewAutoFilter;
using MoreLinq;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace TestApp
{
public partial class Form1 : Form
{
@Zujaj
Zujaj / multi_select_dialog.dart
Last active February 8, 2021 09:58
A Custom Dialog that displays a single title & list of options.
import 'package:flutter/material.dart';
/// A Custom Dialog that displays a single question & list of answers.
class MultiSelectDialog extends StatelessWidget {
/// List to display the answer.
final List<String> answers;
/// Widget to display the question.
final Widget question;
@Zujaj
Zujaj / demo_page.dart
Last active February 9, 2021 08:54
A Demo page that displays an Elevated Button
import 'package:flutter/material.dart';
import 'package:multiple_selection_dialogue_app/widgets/multi_select_dialog.dart';
/// A demo page that displays an [ElevatedButton]
class DemoPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
/// Stores the selected flavours
List<String> flavours = [];