/// <summary> /// Creates an instance of IPAddressData class from an instance of IPAddress. /// </summary> /// <param name="ipRange">IP address to copy into newly created instance.</param> public IPRangeData(IPRange ipRange) { if (ipRange == null) { throw new ArgumentNullException("ipRange"); } Name = ipRange.Name; SubnetPrefixLength = ipRange.SubnetPrefixLength; if (ipRange.Address != null) { Address = ipRange.Address.ToString(); } }
private void textBoxRestrictIP_Validating(object sender, CancelEventArgs e) { TextBox tb = (TextBox)sender; bool Error = false; try { IPRange ip = new IPRange() { Name = "default", Address = IPAddress.Parse(tb.Text) }; } catch { errorProvider1.SetError(tb, "Incorrect IP address"); Error = true; } if (!Error) { errorProvider1.SetError(tb, String.Empty); } }
private void checkIPAddress(TextBox tb) { bool Error = false; try { IPRange ip = new IPRange() { Name = "default", Address = IPAddress.Parse(tb.Text) }; } catch { errorProvider1.SetError(tb, "Incorrect IP address"); Error = true; } if (!Error) { errorProvider1.SetError(tb, String.Empty); } }