Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10.  
  11. namespace Kadai03
  12. {
  13. public partial class FrmMeibo : Form
  14. {
  15. private const string MEIBOFILE = @"Z:\WinPro\Lesson04\Meibo.txt";
  16.  
  17. StreamReader reader = new StreamReader(MEIBOFILE);
  18. private DialogResult ret;
  19.  
  20. public FrmMeibo()
  21. {
  22. InitializeComponent();
  23. }
  24.  
  25. private void FrmMeibo_Load(object sender, EventArgs e)
  26. {
  27. FrmLogin form = new FrmLogin();
  28.  
  29. ret = form.ShowDialog();
  30.  
  31. if (reader.Peek() != -1)
  32. {
  33. string line = reader.ReadLine();
  34. char[] separate = { ',' };
  35. string[] fields = line.Split(separate);
  36.  
  37. txtName.Text = fields[0];
  38. txtSeibetu.Text = fields[1];
  39. txtJusyo.Text = fields[2];
  40. }
  41. }
  42.  
  43. private void btnNext_Click(object sender, EventArgs e)
  44. {
  45. if (ret == DialogResult.OK)
  46. {
  47. if (reader.Peek() != -1)
  48. {
  49.  
  50. string line = reader.ReadLine();
  51. char[] separate = { ',' };
  52. string[] fields = line.Split(separate);
  53.  
  54. txtName.Text = fields[0];
  55. txtSeibetu.Text = fields[1];
  56. txtJusyo.Text = fields[2];
  57. }
  58.  
  59. else
  60. {
  61. MessageBox.Show("終わりです", "EOF", MessageBoxButtons.OK, MessageBoxIcon.Error);
  62. }
  63. }
  64.  
  65. }
  66.  
  67. private void FrmMeibo_FormClosing(object sender, FormClosingEventArgs e)
  68. {
  69. reader.Close();
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement