Есть 2 файла Form2.cs:
и второй файл Form2.Designer.cs:
Вот так выглядит форма:
Вопрос:
Нужны следующие проверки
1. Первые 3 октета IP адресов из обоих полей должны быть одинаковые.
2. 4-ый октет первого IP-адреса должен быть меньше 4-го октета второго IP-адреса.
Помогите пожалуйста, что мне прописать в коде?
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MyPCProject
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void ipAddressControl1_KeyDown(object sender, KeyEventArgs e)
{
Console.WriteLine("KeyDown: {0}", e.KeyValue);
}
private void ipAddressControl1_KeyPress(object sender, KeyPressEventArgs e)
{
Console.WriteLine("KeyPress: {0}", Convert.ToInt32(e.KeyChar));
}
private void ipAddressControl1_KeyUp(object sender, KeyEventArgs e)
{
Console.WriteLine("KeyUp: {0}", e.KeyValue);
}
private void ipAddressControl1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
Console.WriteLine("PreviewKeyDown: {0}", e.KeyValue);
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
C#:
namespace MyPCProject
{
partial class Form2
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.ipAddressControl2 = new IPAddressControlLib.IPAddressControl();
this.ipAddressControl1 = new IPAddressControlLib.IPAddressControl();
this.button1 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.ipAddressControl2);
this.groupBox1.Controls.Add(this.ipAddressControl1);
this.groupBox1.Location = new System.Drawing.Point(12, 5);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(152, 109);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Из диапазона IP-адресов";
this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
//
// ipAddressControl2
//
this.ipAddressControl2.AllowInternalTab = false;
this.ipAddressControl2.AutoHeight = true;
this.ipAddressControl2.BackColor = System.Drawing.SystemColors.Window;
this.ipAddressControl2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.ipAddressControl2.Cursor = System.Windows.Forms.Cursors.IBeam;
this.ipAddressControl2.Location = new System.Drawing.Point(6, 50);
this.ipAddressControl2.MinimumSize = new System.Drawing.Size(87, 20);
this.ipAddressControl2.Name = "ipAddressControl2";
this.ipAddressControl2.ReadOnly = false;
this.ipAddressControl2.Size = new System.Drawing.Size(140, 20);
this.ipAddressControl2.TabIndex = 2;
this.ipAddressControl2.Text = "...";
this.ipAddressControl2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ipAddressControl1_KeyDown);
this.ipAddressControl2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ipAddressControl1_KeyPress);
this.ipAddressControl2.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ipAddressControl1_KeyUp);
this.ipAddressControl2.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.ipAddressControl1_PreviewKeyDown);
//
// ipAddressControl1
//
this.ipAddressControl1.AllowInternalTab = false;
this.ipAddressControl1.AutoHeight = true;
this.ipAddressControl1.BackColor = System.Drawing.SystemColors.Window;
this.ipAddressControl1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.ipAddressControl1.Cursor = System.Windows.Forms.Cursors.IBeam;
this.ipAddressControl1.Location = new System.Drawing.Point(6, 20);
this.ipAddressControl1.MinimumSize = new System.Drawing.Size(87, 20);
this.ipAddressControl1.Name = "ipAddressControl1";
this.ipAddressControl1.ReadOnly = false;
this.ipAddressControl1.Size = new System.Drawing.Size(140, 20);
this.ipAddressControl1.TabIndex = 1;
this.ipAddressControl1.Text = "...";
this.ipAddressControl1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ipAddressControl1_KeyDown);
this.ipAddressControl1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ipAddressControl1_KeyPress);
this.ipAddressControl1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ipAddressControl1_KeyUp);
this.ipAddressControl1.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.ipAddressControl1_PreviewKeyDown);
//
// button1
//
this.button1.Location = new System.Drawing.Point(24, 76);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(106, 23);
this.button1.TabIndex = 3;
this.button1.Text = "Собрать данные";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(176, 450);
this.Controls.Add(this.groupBox1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form2";
this.Text = "Сбор данных";
this.Load += new System.EventHandler(this.Form2_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private IPAddressControlLib.IPAddressControl ipAddressControl1;
private IPAddressControlLib.IPAddressControl ipAddressControl2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button button1;
}
}
Вопрос:
Нужны следующие проверки
1. Первые 3 октета IP адресов из обоих полей должны быть одинаковые.
2. 4-ый октет первого IP-адреса должен быть меньше 4-го октета второго IP-адреса.
Помогите пожалуйста, что мне прописать в коде?