Vijay Yadav

Vijay Yadav

  • NA
  • 1.4k
  • 651k

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

Jun 15 2011 10:44 AM

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)