ListViewItem temp = new ListViewItem("11");
listView1.Items.Add(temp);
listView1.EnsureVisible(listView1.Items.Count - 1);

마지막에 추가한 아이템에 포커스

'Programming > C#' 카테고리의 다른 글

c# 크로스 스레드  (0) 2020.01.29
c# ping test  (0) 2020.01.29
monodevelop Mysql  (0) 2020.01.29
C# ListView 선택된 아이템 가져오기  (0) 2020.01.29
c# Mysql  (0) 2020.01.29
public void test(string str)
{
    // 생성된 스레드가 아닌 다른 스레드에서 호출 -> true, 정상 -> false
    if (this.InvokeRequired)
    {
        this.Invoke(new MethodInvoker(delegate ()
        {
            label1.Text = str;
        }));
    }
    else
    {
        label1.Text = str;
    }
}

 

'Programming > C#' 카테고리의 다른 글

c# ListView 추가한 아이템 포커스  (0) 2020.01.29
c# ping test  (0) 2020.01.29
monodevelop Mysql  (0) 2020.01.29
C# ListView 선택된 아이템 가져오기  (0) 2020.01.29
c# Mysql  (0) 2020.01.29
 private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 1; i <= 255; i++)
            {
                new Thread(() =>
                {
                    int ip = i;
                    try
                    {
                        Ping ping = new Ping();
                        int timeout = 10;

                        PingReply reply = ping.Send(IPAddress.Parse("192.168.0." + ip.ToString()), timeout);

                        if (reply.Status == IPStatus.Success)
                        {
                            Console.WriteLine("Succeess");
                            ListViewItem temp = new ListViewItem("192.168.0." + ip.ToString() + "Succeess");
                            listView1.Items.Add(temp);
                        }
                        else
                        {
                            Console.WriteLine("Fail");
                            ListViewItem temp = new ListViewItem("192.168.0." + ip.ToString() + "Fail");
                            listView1.Items.Add(temp);
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                    }

                }).Start();
            }
        }

버튼 생성

listview 생성

 

핑테스트가 완료되면 listview에 추가됨

'Programming > C#' 카테고리의 다른 글

c# ListView 추가한 아이템 포커스  (0) 2020.01.29
c# 크로스 스레드  (0) 2020.01.29
monodevelop Mysql  (0) 2020.01.29
C# ListView 선택된 아이템 가져오기  (0) 2020.01.29
c# Mysql  (0) 2020.01.29
string connectionString =
	"Server=127.0.0.1;" +
	"Database=test;" +
	"User ID=root;" +
	"Password=password;" +
	"Pooling=false";
IDbConnection dbcon;

dbcon = new MySqlConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();

string sql ="SELECT * FROM mamber";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
	string FirstName = reader[name].ToString();
	Console.WriteLine("Name: " + FirstName);
}

reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;

 

'Programming > C#' 카테고리의 다른 글

c# 크로스 스레드  (0) 2020.01.29
c# ping test  (0) 2020.01.29
C# ListView 선택된 아이템 가져오기  (0) 2020.01.29
c# Mysql  (0) 2020.01.29
c# MessageBox 예 아니오 선택  (0) 2020.01.29
if (listView1.SelectedIndices.Count > 0)
{
	string idx = listView1.Items[listView1.FocusedItem.Index].SubItems[0].Text.ToString();
}

 

'Programming > C#' 카테고리의 다른 글

c# ping test  (0) 2020.01.29
monodevelop Mysql  (0) 2020.01.29
c# Mysql  (0) 2020.01.29
c# MessageBox 예 아니오 선택  (0) 2020.01.29
c# textbox 비밀번호  (0) 2020.01.29
private static MySqlConnection mySqlConn; //선언

public static void DBConn()
{
	//연결
	try
	{
		string strconn = "Server=127.0.0.1;Database=test;Uid=root;Pwd=apmsetup;";
		mySqlConn = new MySqlConnection(strconn);
		mySqlConn.Open();
	}
	catch (Exception ex)
	{
		Console.WriteLine("연결 실패\n인터넷 연결을 확인해주세요\n" + ex.Message);
	}
	finally
	{
	}
}
public static MySqlConnection getInsent()
        {
            if (mySqlConn == null || mySqlConn.State != System.Data.ConnectionState.Open || mySqlConn.Ping() == false)
            {
                DBConn();
                Console.WriteLine("DB재연결");
            }

            return mySqlConn;
        }


public void sendMSG()
{
	try
	{
		// MYSQL 내보내기                
		string msg = "SELECT * FROM member WHERE Idx = 1;";
		// MYSQL 내보내기
		// 날릴 쿼리가 있으면
		string str = "";
		if (!(msg == ""))
		{
			using (MySqlCommand count = new MySqlCommand(msg, mySqlConn))
			{
				//count.ExecuteNonQuery(); 
				MySqlDataReader myCount = count.ExecuteReader();
				while (myCount.Read())
				{
					str = myCount["Name"].ToString();
				}
				myCount.Close();
			}
		}
	}
	catch (Exception ex)
	{
		Console.WriteLine("READ Error!\n" + ex.Message);
	}
	finally
	{
	}
}

'Programming > C#' 카테고리의 다른 글

monodevelop Mysql  (0) 2020.01.29
C# ListView 선택된 아이템 가져오기  (0) 2020.01.29
c# MessageBox 예 아니오 선택  (0) 2020.01.29
c# textbox 비밀번호  (0) 2020.01.29
c# ini  (0) 2020.01.29
if (MessageBox.Show("확인 취소 테스트", "확인", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
     //확인시 내용
     MessageBox.Show("확인버튼 누름");
}

'Programming > C#' 카테고리의 다른 글

C# ListView 선택된 아이템 가져오기  (0) 2020.01.29
c# Mysql  (0) 2020.01.29
c# textbox 비밀번호  (0) 2020.01.29
c# ini  (0) 2020.01.29
c# 시리얼통신  (0) 2020.01.29

텍스트 박스 선택

 

속성에서 PasswordChar 에서 대체할 기호를 입력

 

'Programming > C#' 카테고리의 다른 글

C# ListView 선택된 아이템 가져오기  (0) 2020.01.29
c# Mysql  (0) 2020.01.29
c# MessageBox 예 아니오 선택  (0) 2020.01.29
c# ini  (0) 2020.01.29
c# 시리얼통신  (0) 2020.01.29

+ Recent posts