|
-
March 3rd, 2020, 12:58 AM
#1
Datagrid-forloop behavior
Hello experts
I have this behavior that I cannot figure it out. The following code is triggered by a button
Code:
try
{
Type typeFWPolicy2 = Type.GetTypeFromProgID("HNetCfg.FwPolicy2");
INetFwPolicy2 fwPolicy2 = (INetFwPolicy2)Activator.CreateInstance(typeFWPolicy2);
foreach (INetFwRule rule in fwPolicy2.Rules)
{
lvItems.RuleName = rule.Name; ;
lvItems.RemoteAddress = rule.RemoteAddresses;
lvItems.Protocol = rule.Protocol.ToString();
lvItems.LocalPort = rule.LocalPorts;
dataGrid1.Items.Add(lvItems);
//MessageBox.Show("close me");
}
}
catch (Exception ex)
{
MessageBox.Show("something went wrong");
}
When I run it, the datagrid is populated with the same record (first) entry that is repeated several times.
then I added a Messagebox to troubleshoot, then Datagrid is populated correctly but I need to acknowledge each Messagebox !!!!. It is like it just needs that extra mouse click.
any help is greatly appreciated
Last edited by 2kaud; March 3rd, 2020 at 04:23 AM.
Reason: Added code tags
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|