├── .gitattributes
├── .gitignore
├── DataGridViewButtonDemo.sln
├── DataGridViewButtonDemo
├── App.config
├── DataGridViewButtonDemo.csproj
├── DataGridViewCellButtonHelper
│ ├── CellButtonCtrl.Designer.cs
│ ├── CellButtonCtrl.cs
│ └── CellButtonCtrl.resx
├── Dialogs
│ ├── OptionSelectionForm.Designer.cs
│ ├── OptionSelectionForm.cs
│ └── OptionSelectionForm.resx
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Images
│ ├── bullet_blue16.png
│ ├── bullet_green16.png
│ ├── bullet_orange16.png
│ └── bullet_red16.png
├── MyCellButton.cs
├── Program.cs
└── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── README.md
└── gifdemo.gif
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Windows Store app package directory
170 | AppPackages/
171 | BundleArtifacts/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | [Ss]tyle[Cc]op.*
182 | ~$*
183 | *~
184 | *.dbmdl
185 | *.dbproj.schemaview
186 | *.pfx
187 | *.publishsettings
188 | node_modules/
189 | orleans.codegen.cs
190 |
191 | # RIA/Silverlight projects
192 | Generated_Code/
193 |
194 | # Backup & report files from converting an old project file
195 | # to a newer Visual Studio version. Backup files are not needed,
196 | # because we have git ;-)
197 | _UpgradeReport_Files/
198 | Backup*/
199 | UpgradeLog*.XML
200 | UpgradeLog*.htm
201 |
202 | # SQL Server files
203 | *.mdf
204 | *.ldf
205 |
206 | # Business Intelligence projects
207 | *.rdl.data
208 | *.bim.layout
209 | *.bim_*.settings
210 |
211 | # Microsoft Fakes
212 | FakesAssemblies/
213 |
214 | # GhostDoc plugin setting file
215 | *.GhostDoc.xml
216 |
217 | # Node.js Tools for Visual Studio
218 | .ntvs_analysis.dat
219 |
220 | # Visual Studio 6 build log
221 | *.plg
222 |
223 | # Visual Studio 6 workspace options file
224 | *.opt
225 |
226 | # Visual Studio LightSwitch build output
227 | **/*.HTMLClient/GeneratedArtifacts
228 | **/*.DesktopClient/GeneratedArtifacts
229 | **/*.DesktopClient/ModelManifest.xml
230 | **/*.Server/GeneratedArtifacts
231 | **/*.Server/ModelManifest.xml
232 | _Pvt_Extensions
233 |
234 | # LightSwitch generated files
235 | GeneratedArtifacts/
236 | ModelManifest.xml
237 |
238 | # Paket dependency manager
239 | .paket/paket.exe
240 |
241 | # FAKE - F# Make
242 | .fake/
243 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataGridViewButtonDemo", "DataGridViewButtonDemo\DataGridViewButtonDemo.csproj", "{B5C63364-BC9F-4E4D-882A-DEBDA49CCA1C}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B5C63364-BC9F-4E4D-882A-DEBDA49CCA1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B5C63364-BC9F-4E4D-882A-DEBDA49CCA1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B5C63364-BC9F-4E4D-882A-DEBDA49CCA1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B5C63364-BC9F-4E4D-882A-DEBDA49CCA1C}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/DataGridViewButtonDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {B5C63364-BC9F-4E4D-882A-DEBDA49CCA1C}
8 | WinExe
9 | Properties
10 | DataGridViewButtonDemo
11 | DataGridViewButtonDemo
12 | v4.5.2
13 | 512
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | UserControl
51 |
52 |
53 | CellButtonCtrl.cs
54 |
55 |
56 | Form
57 |
58 |
59 | OptionSelectionForm.cs
60 |
61 |
62 | Form
63 |
64 |
65 | Form1.cs
66 |
67 |
68 | UserControl
69 |
70 |
71 |
72 |
73 | CellButtonCtrl.cs
74 |
75 |
76 | OptionSelectionForm.cs
77 |
78 |
79 | Form1.cs
80 |
81 |
82 | ResXFileCodeGenerator
83 | Resources.Designer.cs
84 | Designer
85 |
86 |
87 | True
88 | Resources.resx
89 | True
90 |
91 |
92 | SettingsSingleFileGenerator
93 | Settings.Designer.cs
94 |
95 |
96 | True
97 | Settings.settings
98 | True
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
125 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/DataGridViewCellButtonHelper/CellButtonCtrl.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace DataGridViewButtonDemo.DataGridViewCellButtonHelper
2 | {
3 | partial class CellButtonCtrl
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.buttonCellAction = new System.Windows.Forms.Button();
32 | this.SuspendLayout();
33 | //
34 | // buttonCellAction
35 | //
36 | this.buttonCellAction.Image = global::DataGridViewButtonDemo.Properties.Resources.bullet_blue16;
37 | this.buttonCellAction.Location = new System.Drawing.Point(0, 0);
38 | this.buttonCellAction.Name = "buttonCellAction";
39 | this.buttonCellAction.Size = new System.Drawing.Size(25, 21);
40 | this.buttonCellAction.TabIndex = 1;
41 | this.buttonCellAction.UseVisualStyleBackColor = true;
42 | this.buttonCellAction.Click += new System.EventHandler(this.buttonCellAction_Click);
43 | //
44 | // CellButtonCtrl
45 | //
46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
48 | this.Controls.Add(this.buttonCellAction);
49 | this.Name = "CellButtonCtrl";
50 | this.Size = new System.Drawing.Size(24, 23);
51 | this.ResumeLayout(false);
52 |
53 | }
54 |
55 | #endregion
56 |
57 | private System.Windows.Forms.Button buttonCellAction;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/DataGridViewCellButtonHelper/CellButtonCtrl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace DataGridViewButtonDemo.DataGridViewCellButtonHelper
12 | {
13 | public partial class CellButtonCtrl : UserControl
14 | {
15 | DataGridView m_hostDgvCtrl = null;
16 |
17 | public int HostDgvColumnIndex { get; set; }
18 | public int HostDgvRowIndex { get; set; }
19 |
20 | public CellButtonCtrl(DataGridView dgv)
21 | {
22 | InitializeComponent();
23 |
24 | if (dgv == null) throw new ArgumentNullException("DataGridView cannot be null");
25 |
26 | m_hostDgvCtrl = dgv;
27 |
28 | SetupSmartButtonCtrl();
29 | }
30 |
31 | public DataGridView GetHostDataGridViewCtrl()
32 | {
33 | return m_hostDgvCtrl;
34 | }
35 |
36 | private void SetupSmartButtonCtrl()
37 | {
38 | try
39 | {
40 | this.Visible = false;
41 | m_hostDgvCtrl?.Controls.Add(this);
42 | }
43 | catch (Exception ex)
44 | {
45 | Console.WriteLine(ex.Message);
46 | }
47 | }
48 |
49 | public void SetupButtonImage(Bitmap image)
50 | {
51 | buttonCellAction.Image = image;
52 | }
53 |
54 | public virtual void DisplayCellButton(int ColumnIndex, int RowIndex)
55 | {
56 | Console.WriteLine("Ticks: {0}, Cell Button Clicked. Row: {1}, Col: {2}", DateTime.Now.Ticks, ColumnIndex, RowIndex);
57 |
58 | HostDgvColumnIndex = ColumnIndex;
59 | HostDgvRowIndex = RowIndex;
60 |
61 | // Work out the location of where to display the button!
62 | var dgv = GetHostDataGridViewCtrl();
63 | int cellHeight = dgv.Rows[RowIndex].Height;
64 | int cellWidth = dgv.Columns[ColumnIndex].Width;
65 | this.Height = cellHeight - 2;
66 | var cellProps = dgv.Rows[RowIndex].Cells[ColumnIndex].ContentBounds;
67 | var loc = dgv.GetCellDisplayRectangle(ColumnIndex, RowIndex, true).Location;
68 | this.Location = new Point(loc.X + cellWidth - (this.Width + 2), loc.Y);
69 | //this.Visible = true;
70 | }
71 |
72 | public void HideCellButton()
73 | {
74 | Console.WriteLine("Hide Cell Button");
75 | this.Visible = false;
76 | }
77 |
78 | public virtual void buttonCellAction_Click(object sender, EventArgs e)
79 | {
80 | MessageBox.Show("base class");
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/DataGridViewCellButtonHelper/CellButtonCtrl.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Dialogs/OptionSelectionForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace DataGridViewButtonDemo.Dialogs
2 | {
3 | partial class OptionSelectionForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.label1 = new System.Windows.Forms.Label();
32 | this.textBoxFilter = new System.Windows.Forms.TextBox();
33 | this.listView = new System.Windows.Forms.ListView();
34 | this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
35 | this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
36 | this.buttonOK = new System.Windows.Forms.Button();
37 | this.buttonCancel = new System.Windows.Forms.Button();
38 | this.SuspendLayout();
39 | //
40 | // label1
41 | //
42 | this.label1.AutoSize = true;
43 | this.label1.Location = new System.Drawing.Point(4, 8);
44 | this.label1.Name = "label1";
45 | this.label1.Size = new System.Drawing.Size(29, 13);
46 | this.label1.TabIndex = 111;
47 | this.label1.Text = "Filter";
48 | //
49 | // textBoxFilter
50 | //
51 | this.textBoxFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
52 | | System.Windows.Forms.AnchorStyles.Right)));
53 | this.textBoxFilter.Location = new System.Drawing.Point(39, 5);
54 | this.textBoxFilter.Name = "textBoxFilter";
55 | this.textBoxFilter.Size = new System.Drawing.Size(246, 20);
56 | this.textBoxFilter.TabIndex = 110;
57 | //
58 | // listView
59 | //
60 | this.listView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
61 | | System.Windows.Forms.AnchorStyles.Left)
62 | | System.Windows.Forms.AnchorStyles.Right)));
63 | this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
64 | this.columnHeader1,
65 | this.columnHeader2});
66 | this.listView.Location = new System.Drawing.Point(4, 31);
67 | this.listView.Name = "listView";
68 | this.listView.Size = new System.Drawing.Size(285, 157);
69 | this.listView.TabIndex = 109;
70 | this.listView.UseCompatibleStateImageBehavior = false;
71 | this.listView.View = System.Windows.Forms.View.Details;
72 | this.listView.SelectedIndexChanged += new System.EventHandler(this.listView_SelectedIndexChanged);
73 | this.listView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listView_MouseDoubleClick);
74 | //
75 | // columnHeader1
76 | //
77 | this.columnHeader1.Text = "Id";
78 | this.columnHeader1.Width = 29;
79 | //
80 | // columnHeader2
81 | //
82 | this.columnHeader2.Text = "Value";
83 | this.columnHeader2.Width = 226;
84 | //
85 | // buttonOK
86 | //
87 | this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
88 | this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
89 | this.buttonOK.Location = new System.Drawing.Point(199, 194);
90 | this.buttonOK.Name = "buttonOK";
91 | this.buttonOK.Size = new System.Drawing.Size(37, 23);
92 | this.buttonOK.TabIndex = 108;
93 | this.buttonOK.Text = "OK";
94 | this.buttonOK.UseVisualStyleBackColor = true;
95 | //
96 | // buttonCancel
97 | //
98 | this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
99 | this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
100 | this.buttonCancel.Location = new System.Drawing.Point(240, 194);
101 | this.buttonCancel.Name = "buttonCancel";
102 | this.buttonCancel.Size = new System.Drawing.Size(49, 23);
103 | this.buttonCancel.TabIndex = 107;
104 | this.buttonCancel.Text = "Cancel";
105 | this.buttonCancel.UseVisualStyleBackColor = true;
106 | //
107 | // OptionSelectionForm
108 | //
109 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
110 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
111 | this.ClientSize = new System.Drawing.Size(296, 223);
112 | this.Controls.Add(this.label1);
113 | this.Controls.Add(this.textBoxFilter);
114 | this.Controls.Add(this.listView);
115 | this.Controls.Add(this.buttonOK);
116 | this.Controls.Add(this.buttonCancel);
117 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
118 | this.Name = "OptionSelectionForm";
119 | this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
120 | this.Text = "Option Selection";
121 | this.Load += new System.EventHandler(this.OptionSelectionForm_Load);
122 | this.ResumeLayout(false);
123 | this.PerformLayout();
124 |
125 | }
126 |
127 | #endregion
128 |
129 | private System.Windows.Forms.Label label1;
130 | private System.Windows.Forms.TextBox textBoxFilter;
131 | private System.Windows.Forms.ListView listView;
132 | private System.Windows.Forms.ColumnHeader columnHeader1;
133 | private System.Windows.Forms.ColumnHeader columnHeader2;
134 | private System.Windows.Forms.Button buttonOK;
135 | private System.Windows.Forms.Button buttonCancel;
136 | }
137 | }
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Dialogs/OptionSelectionForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace DataGridViewButtonDemo.Dialogs
12 | {
13 | public partial class OptionSelectionForm : Form
14 | {
15 | public string SelectedItem { get; set; }
16 | public OptionSelectionForm(Point location)
17 | {
18 | InitializeComponent();
19 | this.Location = location;
20 | }
21 |
22 | private void OptionSelectionForm_Load(object sender, EventArgs e)
23 | {
24 | PopulateList();
25 | }
26 |
27 | private void PopulateList()
28 | {
29 | try
30 | {
31 | listView.FullRowSelect = true;
32 | listView.Columns[0].Width = 30;
33 | listView.Columns[1].Width = 200;
34 |
35 | listView.Items.Clear();
36 |
37 | int id = 1;
38 | listView.Items.Add(CreateListViewItem(id++, "Accounting"));
39 | listView.Items.Add(CreateListViewItem(id++, "Production"));
40 | listView.Items.Add(CreateListViewItem(id++, "HR"));
41 | listView.Items.Add(CreateListViewItem(id++, "Marketing"));
42 | listView.Items.Add(CreateListViewItem(id++, "Pilot"));
43 | listView.Items.Add(CreateListViewItem(id++, "Laundry"));
44 | }
45 | catch (Exception ex)
46 | {
47 | }
48 | }
49 |
50 | private ListViewItem CreateListViewItem(int id, string name)
51 | {
52 | ListViewItem itm = new ListViewItem(id.ToString());
53 | itm.SubItems.Add(name);
54 |
55 | return itm;
56 | }
57 |
58 | private void listView_SelectedIndexChanged(object sender, EventArgs e)
59 | {
60 | if (listView.SelectedItems.Count == 1)
61 | {
62 | ListViewItem lvItem = listView.SelectedItems[0];
63 | SelectedItem = lvItem.SubItems[1].Text;
64 | }
65 | }
66 |
67 | private void listView_MouseDoubleClick(object sender, MouseEventArgs e)
68 | {
69 | if (listView.SelectedItems.Count == 1)
70 | {
71 | ListViewItem lvItem = listView.SelectedItems[0];
72 | SelectedItem = lvItem.SubItems[1].Text;
73 | this.DialogResult = DialogResult.OK;
74 | }
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Dialogs/OptionSelectionForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace DataGridViewButtonDemo
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.dataGridView = new System.Windows.Forms.DataGridView();
32 | this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
33 | this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
34 | this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
35 | this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
36 | this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
37 | this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
38 | this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
39 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
40 | this.SuspendLayout();
41 | //
42 | // dataGridView
43 | //
44 | this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
45 | this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
46 | this.Column1,
47 | this.Column2,
48 | this.Column3,
49 | this.Column4,
50 | this.Column5,
51 | this.Column6,
52 | this.Column7});
53 | this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
54 | this.dataGridView.Location = new System.Drawing.Point(0, 0);
55 | this.dataGridView.Name = "dataGridView";
56 | this.dataGridView.Size = new System.Drawing.Size(716, 237);
57 | this.dataGridView.TabIndex = 0;
58 | this.dataGridView.CellMouseEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellMouseEnter);
59 | this.dataGridView.CellMouseLeave += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellMouseLeave);
60 | //
61 | // Column1
62 | //
63 | this.Column1.HeaderText = "Id";
64 | this.Column1.Name = "Column1";
65 | this.Column1.Width = 50;
66 | //
67 | // Column2
68 | //
69 | this.Column2.HeaderText = "First Name";
70 | this.Column2.Name = "Column2";
71 | //
72 | // Column3
73 | //
74 | this.Column3.HeaderText = "Last Name";
75 | this.Column3.Name = "Column3";
76 | //
77 | // Column4
78 | //
79 | this.Column4.HeaderText = "Department";
80 | this.Column4.Name = "Column4";
81 | //
82 | // Column5
83 | //
84 | this.Column5.HeaderText = "Salary Band";
85 | this.Column5.Name = "Column5";
86 | //
87 | // Column6
88 | //
89 | this.Column6.HeaderText = "IsManager";
90 | this.Column6.Name = "Column6";
91 | this.Column6.Width = 80;
92 | //
93 | // Column7
94 | //
95 | this.Column7.HeaderText = "Perf Score";
96 | this.Column7.Name = "Column7";
97 | //
98 | // Form1
99 | //
100 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
101 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
102 | this.ClientSize = new System.Drawing.Size(716, 237);
103 | this.Controls.Add(this.dataGridView);
104 | this.Name = "Form1";
105 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
106 | this.Text = "DataGridViewCellButtonHelper - Ocean Airdrop";
107 | this.Load += new System.EventHandler(this.Form1_Load);
108 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
109 | this.ResumeLayout(false);
110 |
111 | }
112 |
113 | #endregion
114 |
115 | private System.Windows.Forms.DataGridView dataGridView;
116 | private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
117 | private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
118 | private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
119 | private System.Windows.Forms.DataGridViewTextBoxColumn Column4;
120 | private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
121 | private System.Windows.Forms.DataGridViewTextBoxColumn Column6;
122 | private System.Windows.Forms.DataGridViewTextBoxColumn Column7;
123 | }
124 | }
125 |
126 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace DataGridViewButtonDemo
12 | {
13 | public partial class Form1 : Form
14 | {
15 | MyCellButton m_myCellButton;
16 |
17 | public Form1()
18 | {
19 | InitializeComponent();
20 | }
21 |
22 | private void Form1_Load(object sender, EventArgs e)
23 | {
24 | StyleDataGridView(dataGridView);
25 | PopulateDataGridView(dataGridView);
26 | SetupSmartButtonCtrl();
27 | }
28 |
29 | public void StyleDataGridView(DataGridView dgv)
30 | {
31 | try
32 | {
33 | dgv.ColumnHeadersDefaultCellStyle.Font = new Font("Segoe UI", 9, FontStyle.Bold, GraphicsUnit.Point);
34 | dgv.DefaultCellStyle.Font = new Font("Segoe UI", 9, FontStyle.Regular, GraphicsUnit.Point);
35 | dgv.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
36 | dgv.CellBorderStyle = DataGridViewCellBorderStyle.Single;
37 | dgv.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
38 | dgv.ColumnHeadersDefaultCellStyle.BackColor = SystemColors.ControlDark;
39 | dgv.DefaultCellStyle.BackColor = Color.Empty;
40 | dgv.AllowUserToAddRows = false;
41 | }
42 | catch (Exception ex)
43 | {
44 | Console.WriteLine(ex.Message);
45 | }
46 | }
47 |
48 | public void PopulateDataGridView(DataGridView dgv)
49 | {
50 | AddToDataGridView(1, "Chris", "Barrie", "HR", "band 2", false, "Below Average");
51 | AddToDataGridView(2, "Craig", "Charles", "Reception", "band 3", false, "Meh");
52 | AddToDataGridView(3, "Danny", "John Jules", "Pilot", "band 1", false, "Needs Improvement");
53 | AddToDataGridView(4, "Robert", "Llewellyn", "Laundry", "band 3", false, "Awesome");
54 | }
55 |
56 | private void AddToDataGridView(int id, string firstName, string lastName, string dept, string salaryBand, bool isManager, string perfScore)
57 | {
58 | int nNewRow = dataGridView.Rows.Add();
59 |
60 | int nColCount = 0;
61 | dataGridView.Rows[nNewRow].Cells[nColCount++].Value = id;
62 | dataGridView.Rows[nNewRow].Cells[nColCount++].Value = firstName;
63 | dataGridView.Rows[nNewRow].Cells[nColCount++].Value = lastName;
64 | dataGridView.Rows[nNewRow].Cells[nColCount++].Value = dept;
65 | dataGridView.Rows[nNewRow].Cells[nColCount++].Value = salaryBand;
66 | dataGridView.Rows[nNewRow].Cells[nColCount++].Value = isManager;
67 | dataGridView.Rows[nNewRow].Cells[nColCount++].Value = perfScore;
68 | }
69 |
70 | private void SetupSmartButtonCtrl()
71 | {
72 | m_myCellButton = new MyCellButton(dataGridView);
73 | m_myCellButton.SetupButtonImage(global::DataGridViewButtonDemo.Properties.Resources.bullet_red16);
74 | }
75 |
76 | private void dataGridView_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
77 | {
78 | if (e.RowIndex < 0 || e.ColumnIndex < 0)
79 | return;
80 |
81 | m_myCellButton?.DisplayCellButton(e.ColumnIndex, e.RowIndex);
82 | }
83 |
84 | private void dataGridView_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
85 | {
86 | if (this.dataGridView.Focused == false)
87 | {
88 | // Hide the cell button!
89 | m_myCellButton?.HideCellButton();
90 | }
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | True
122 |
123 |
124 | True
125 |
126 |
127 | True
128 |
129 |
130 | True
131 |
132 |
133 | True
134 |
135 |
136 | True
137 |
138 |
139 | True
140 |
141 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Images/bullet_blue16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OceanAirdrop/DataGridViewCellButtonDemo/f17ae5dbd39d95408565be09115c7a93ebda16e2/DataGridViewButtonDemo/Images/bullet_blue16.png
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Images/bullet_green16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OceanAirdrop/DataGridViewCellButtonDemo/f17ae5dbd39d95408565be09115c7a93ebda16e2/DataGridViewButtonDemo/Images/bullet_green16.png
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Images/bullet_orange16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OceanAirdrop/DataGridViewCellButtonDemo/f17ae5dbd39d95408565be09115c7a93ebda16e2/DataGridViewButtonDemo/Images/bullet_orange16.png
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Images/bullet_red16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OceanAirdrop/DataGridViewCellButtonDemo/f17ae5dbd39d95408565be09115c7a93ebda16e2/DataGridViewButtonDemo/Images/bullet_red16.png
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/MyCellButton.cs:
--------------------------------------------------------------------------------
1 | using DataGridViewButtonDemo.DataGridViewCellButtonHelper;
2 | using DataGridViewButtonDemo.Dialogs;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 |
11 | namespace DataGridViewButtonDemo
12 | {
13 | class MyCellButton : CellButtonCtrl
14 | {
15 | public enum CellButtonColumns
16 | {
17 | Department = 3,
18 | SalryBand = 4,
19 | PerfScore = 6,
20 | }
21 |
22 | public MyCellButton(DataGridView dgv) : base(dgv)
23 | {
24 | Color veryLightGrey = Color.FromArgb(248, 250, 246);
25 |
26 | ColourBackgroundCells(veryLightGrey);
27 | SetReadOnlyColumns();
28 | }
29 |
30 | private void ColourBackgroundCells(Color grey)
31 | {
32 | try
33 | {
34 | var dataGridView = GetHostDataGridViewCtrl();
35 | dataGridView.Columns[(int)CellButtonColumns.Department].DefaultCellStyle.BackColor = grey;
36 | dataGridView.Columns[(int)CellButtonColumns.SalryBand].DefaultCellStyle.BackColor = grey;
37 | dataGridView.Columns[(int)CellButtonColumns.PerfScore].DefaultCellStyle.BackColor = grey;
38 | }
39 | catch (Exception ex)
40 | {
41 | Console.WriteLine(ex.Message);
42 | }
43 | }
44 |
45 | private void SetReadOnlyColumns()
46 | {
47 | var dgv = GetHostDataGridViewCtrl();
48 |
49 | if (dgv.ColumnCount == 0)
50 | return;
51 |
52 | dgv.Columns[(int)CellButtonColumns.Department].ReadOnly = true;
53 | dgv.Columns[(int)CellButtonColumns.SalryBand].ReadOnly = true;
54 | dgv.Columns[(int)CellButtonColumns.PerfScore].ReadOnly = true;
55 | }
56 |
57 | public override void DisplayCellButton(int ColumnIndex, int RowIndex)
58 | {
59 | base.DisplayCellButton(ColumnIndex, RowIndex);
60 |
61 | this.Visible = false;
62 | if (ColumnIndex == (int)CellButtonColumns.Department || ColumnIndex == (int)CellButtonColumns.SalryBand || ColumnIndex == (int)CellButtonColumns.PerfScore)
63 | {
64 | //GetHostDataGridViewCtrl().CurrentCell = GetHostDataGridViewCtrl().Rows[HostDgvRowIndex].Cells[HostDgvColumnIndex];
65 | this.Visible = true;
66 | }
67 | }
68 |
69 | public override void buttonCellAction_Click(object sender, EventArgs e)
70 | {
71 | var dgv = GetHostDataGridViewCtrl();
72 |
73 | Console.WriteLine("Cell Button Clicked. Row: {0}, Col: {1}", HostDgvRowIndex, HostDgvColumnIndex);
74 |
75 | var currentVal = dgv.Rows[HostDgvRowIndex].Cells[HostDgvColumnIndex].Value.ToString();
76 |
77 | if (HostDgvColumnIndex == (int)CellButtonColumns.Department )
78 | {
79 | var form = new OptionSelectionForm(Cursor.Position);
80 | if (form.ShowDialog(this) == DialogResult.OK)
81 | {
82 | dgv.Rows[HostDgvRowIndex].Cells[HostDgvColumnIndex].Value = form.SelectedItem;
83 | dgv.Rows[HostDgvRowIndex].Cells[HostDgvColumnIndex].Style.BackColor = Color.FromArgb(255, 199, 206);
84 | }
85 | }
86 |
87 | if (HostDgvColumnIndex == (int)CellButtonColumns.SalryBand)
88 | {
89 | MessageBox.Show(string.Format("Department - {0}", currentVal));
90 | }
91 |
92 | if (HostDgvColumnIndex == (int)CellButtonColumns.PerfScore)
93 | {
94 | MessageBox.Show(string.Format("PerfScore - {0}", currentVal));
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace DataGridViewButtonDemo
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("DataGridViewButtonDemo")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DataGridViewButtonDemo")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("b5c63364-bc9f-4e4d-882a-debda49cca1c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace DataGridViewButtonDemo.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DataGridViewButtonDemo.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Bitmap.
65 | ///
66 | internal static System.Drawing.Bitmap bullet_blue16 {
67 | get {
68 | object obj = ResourceManager.GetObject("bullet_blue16", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Bitmap.
75 | ///
76 | internal static System.Drawing.Bitmap bullet_green16 {
77 | get {
78 | object obj = ResourceManager.GetObject("bullet_green16", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 |
83 | ///
84 | /// Looks up a localized resource of type System.Drawing.Bitmap.
85 | ///
86 | internal static System.Drawing.Bitmap bullet_orange16 {
87 | get {
88 | object obj = ResourceManager.GetObject("bullet_orange16", resourceCulture);
89 | return ((System.Drawing.Bitmap)(obj));
90 | }
91 | }
92 |
93 | ///
94 | /// Looks up a localized resource of type System.Drawing.Bitmap.
95 | ///
96 | internal static System.Drawing.Bitmap bullet_red16 {
97 | get {
98 | object obj = ResourceManager.GetObject("bullet_red16", resourceCulture);
99 | return ((System.Drawing.Bitmap)(obj));
100 | }
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Images\bullet_blue16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Images\bullet_green16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
128 | ..\Images\bullet_orange16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
129 |
130 |
131 | ..\Images\bullet_red16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
132 |
133 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace DataGridViewButtonDemo.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/DataGridViewButtonDemo/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DataGridViewCellButtonDemo
2 | This demo project shows how you can display a smart helper button in a datagridview cell.
3 |
4 | This project:
5 | * Demonstrates creating a class named MyCellButton which derives from CellButtonCtrl
6 | * Demonstrates changing the image to be displayed on the button
7 | * Demonstrates displaying the button using the CellMouseEnter event
8 | * Demonstrates responding to the button mouse click to display any type of dialog you want.
9 |
10 | 
11 |
12 | Ocean Airdrop - ocean.airdrop@gmail.com
13 |
--------------------------------------------------------------------------------
/gifdemo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OceanAirdrop/DataGridViewCellButtonDemo/f17ae5dbd39d95408565be09115c7a93ebda16e2/gifdemo.gif
--------------------------------------------------------------------------------