@@ -39,6 +39,7 @@ public AzureContextConfigDialog(Settings settings)
3939 _dataGridView . DataSource = _tempAzureContexts ;
4040
4141 _dataGridView . CellToolTipTextNeeded += DataGridView_CellToolTipTextNeeded ;
42+ _dataGridView . MouseDown += DataGridView_MouseDown ; // Attach the MouseDown event handler
4243
4344 _azureService = new AzureService ( _inputSettings ) ;
4445 var azureEnvironments = _azureService . GetAzureEnvironmentNames ( ) ;
@@ -281,22 +282,41 @@ private void MenuItem_SelectTenant_Click(object sender, EventArgs e)
281282 }
282283 }
283284
284- private void DataGridView_CellEndEdit ( object sender , DataGridViewCellEventArgs e )
285+ private void DataGridView_MouseDown ( object sender , MouseEventArgs e )
286+ {
287+ if ( e . Button == MouseButtons . Right )
288+ {
289+ var hitTestInfo = _dataGridView . HitTest ( e . X , e . Y ) ;
290+ if ( hitTestInfo . Type == DataGridViewHitTestType . Cell )
291+ {
292+ _dataGridView . ClearSelection ( ) ;
293+ _dataGridView . Rows [ hitTestInfo . RowIndex ] . Selected = true ;
294+ _dataGridView . CurrentCell = _dataGridView . Rows [ hitTestInfo . RowIndex ] . Cells [ hitTestInfo . ColumnIndex ] ;
295+ UpdateSelectionLabel ( ) ;
296+ }
297+ }
298+ }
299+
300+ private void DataGridView_CellParsing ( object sender , DataGridViewCellParsingEventArgs e )
285301 {
286302 if ( e . ColumnIndex == 0 )
287303 {
288- var azureContextName = _dataGridView . Rows [ e . RowIndex ] . Cells [ e . ColumnIndex ] . Value ? . ToString ( ) ;
304+ var azureContextName = e . Value ? . ToString ( ) ;
289305 if ( string . IsNullOrEmpty ( azureContextName ) )
290306 {
291307 azureContextName = "Default" ;
292308 }
293309 azureContextName = MakeAzureContextNameUnique ( azureContextName ) ;
294- _dataGridView . Rows [ e . RowIndex ] . Cells [ e . ColumnIndex ] . Value = azureContextName ;
310+ e . Value = azureContextName ;
311+ e . ParsingApplied = true ;
312+ }
313+ }
295314
296- if ( _dataGridView . SelectedRows . Count > 0 )
297- {
298- UpdateSelectionLabel ( ) ;
299- }
315+ private void DataGridView_CellEndEdit ( object sender , DataGridViewCellEventArgs e )
316+ {
317+ if ( _dataGridView . SelectedRows . Count > 0 )
318+ {
319+ UpdateSelectionLabel ( ) ;
300320 }
301321 }
302322
@@ -360,7 +380,7 @@ private void KeepContextMenuOpen(bool keepOpen)
360380 }
361381 else
362382 {
363- Task . Delay ( 3000 ) . ContinueWith ( _ =>
383+ Task . Delay ( 2000 ) . ContinueWith ( _ =>
364384 {
365385 _contextMenuShallBeKeptOpen = false ;
366386 if ( _isFormActive )
0 commit comments