4
Answers

how to pass the control to the class file function as a parameter

Vijay Yadav

Vijay Yadav

13y
1.9k
1

I want to pass the control to the class as a parameter

for ex:

in class file, i have the below function:

public void DisableMouseRightClick(Control objControl)

{

var blankContextMenu = new ContextMenu();

foreach (Control control in objControl.Controls)

{

control.ContextMenu = blankContextMenu;

}

}

  

on form load, i have this:

foreach (Control ctl in this.Controls)

{

if (ctl is TextBox

{

classFileObject.DisableMouseRightClick(ctl);

}

}


 but it is not working.

Answers (4)