@@ -141,39 +141,56 @@ private void btnUninstall_Click(object sender, EventArgs e)
141141
142142 private void dataGridView_CellPainting ( object sender , DataGridViewCellPaintingEventArgs e )
143143 {
144- // if (e.ColumnIndex == this.dataGridView1.Columns["ConfiguratorColumn"].Index)
145- if ( e . ColumnIndex == 3 )
144+ if ( e . ColumnIndex == 3 && this . dataGridView1 . SelectedRows . Count > 0 )
146145 {
147146 if ( e . RowIndex > 0 )
148147 {
149- var w = Properties . Resources . ConfigIcon . Width ;
150- var h = Properties . Resources . ConfigIcon . Height ;
151- var x = e . CellBounds . Left + ( e . CellBounds . Width - w ) / 2 ;
152- var y = e . CellBounds . Top + ( e . CellBounds . Height - h ) / 2 ;
153-
154- Bitmap image = Properties . Resources . NoConfigIcon ;
155148 if ( GetConfiguratorPath ( e . RowIndex ) != null )
156149 {
157- image = Properties . Resources . ConfigIcon ;
150+ var w = Properties . Resources . ConfigIcon . Width ;
151+ var h = Properties . Resources . ConfigIcon . Height ;
152+ var x = e . CellBounds . Left + ( e . CellBounds . Width - w ) / 2 ;
153+ var y = e . CellBounds . Top + ( e . CellBounds . Height - h ) / 2 ;
154+
155+ Bitmap image = Properties . Resources . ConfigIcon ;
156+ e . Paint ( e . CellBounds , DataGridViewPaintParts . All ) ;
157+ e . Graphics . DrawImage ( image , new Rectangle ( x , y , w , h ) ) ;
158+ e . Handled = true ;
158159 }
160+ else
161+ {
162+ SolidBrush brush = new SolidBrush ( e . CellStyle . BackColor ) ;
163+ if ( this . dataGridView1 . SelectedRows [ 0 ] . Index == e . RowIndex )
164+ {
165+ brush = new SolidBrush ( e . CellStyle . SelectionBackColor ) ;
166+ }
159167
160- e . Paint ( e . CellBounds , DataGridViewPaintParts . All ) ;
161- e . Graphics . DrawImage ( image , new Rectangle ( x , y , w , h ) ) ;
162- e . Handled = true ;
168+ // ensure we make the cell lines visible
169+ // to make it look consistent
170+ var bounds = e . CellBounds ;
171+ bounds . Height -= 5 ;
172+ bounds . Width -= 5 ;
173+ e . Paint ( bounds , DataGridViewPaintParts . All ) ;
174+ e . Graphics . FillRectangle ( brush , bounds ) ;
175+ e . Handled = true ;
176+ }
163177 }
164178 else
165- {
179+ { // header row
166180 SolidBrush brush = new SolidBrush ( e . CellStyle . BackColor ) ;
167- foreach ( DataGridViewRow selectedRow in this . dataGridView1 . SelectedRows )
181+ if ( this . dataGridView1 . SelectedRows [ 0 ] . Index == 0 )
168182 {
169- if ( selectedRow . Index == 0 )
170- {
171- brush = new SolidBrush ( e . CellStyle . SelectionBackColor ) ;
172- }
183+ brush = new SolidBrush ( e . CellStyle . SelectionBackColor ) ;
173184 }
174185
175- e . Paint ( e . CellBounds , DataGridViewPaintParts . All ) ;
176- e . Graphics . FillRectangle ( brush , e . CellBounds ) ;
186+ // ensure we make the cell lines visible
187+ // to make it look consistent
188+ var bounds = e . CellBounds ;
189+ bounds . Height -= 4 ;
190+ bounds . Width -= 2 ;
191+ bounds . Y += 2 ;
192+ e . Paint ( bounds , DataGridViewPaintParts . All ) ;
193+ e . Graphics . FillRectangle ( brush , bounds ) ;
177194 e . Handled = true ;
178195 }
179196 }
0 commit comments