NickSharp
NickSharp

Reputation: 281

Hides inherited members warning message on my code! - don't know where it come from

I'm new to C#, I have a method which is being called when a BUTTON or a keyboard shortcut is pressed. At first, everything goes smooth, and when I'm almost done with my project, I did some code cleaning up (I erased some comments and removed unnecessary codes). But after that a warning message appears and the keyboard shortcut do not function as it was before here's the warning message:

Warning 1 'Inventory_program.IPForm.Update()' hides inherited member 'System.Windows.Forms.Control.Update()'. Use the new keyword if hiding was intended.

Here's my code:

    private void Update()
    {
     if (getset.clik2 == 1)
       {
         MessageBox.Show("No data to update, dumbass!!", "!!");
       }
     else
       {
         query = @"select ip_address, pc_name, mac_address, users_owner, locations, remarks
                 from it_ip_inventory ";
         dataGridView1.DataSource = exec.InitConn(query);

       }            
    }

I apologize, I don't have the enough popular point to upload an image.

Please help, I don't know how to resolved it. I'm using WinForms.

Upvotes: 3

Views: 4415

Answers (1)

John Alexiou
John Alexiou

Reputation: 29254

The method Update() is defined for the control base class.

See here: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.update.aspx

In your code you can name things the same as existing (inherited) methods, if they have different arguments (overloading). In your case, your Update() has an identical signature as the built-in method.

I suggest you take the opportunity to re-name the method to something more descriptive, like

private void UpdateFromDatabase()
{
}

Upvotes: 6

Related Questions