�@

�A�ځF���H�Ŗ𗧂‹Ɩ��A�v���J���̃q���g

��4�� �K�؂ȗ��x�Ń��C�u���������ĊJ�����Y�ɂ���

�����i�E�i���ʍG�V�j
�iMicrosoft MVP Visual Developer - Visual C# JAN 2005 �| DEC 2007�j
2007/09/21
Page1 Page2

�@��1���́A�f�[�^�x�[�X�����֘A�̎��H�I�ȊJ����@�ɂ‚��Đ��������B�܂���2���̓��[�U�[�E�C���^�[�t�F�C�X���������I�ɊJ�������@����������B��3���́A�N���X�\���𐮂��čė��p�������߂��@����������B

�@����́A�������ו������ēK�؂ȗ��x�ł܂Ƃ߁A��������C�u���������邱�ƂŊJ�����Y�ɂ����@���Љ��B���񂪖{�A�ڂ̍ŏI��ƂȂ�B�Ȃ��A�g�p����f�[�^�ɂ‚��Ă͑O��܂łƓ������̂ł���B

��5. �O�i�p��

���J���q���g9�F�O�i�p��

�@�O�i�p���Ƃ́A���[�U�[�E�C���^�[�t�F�C�X�J���𕪊����ď��������邱�ƂŁA�����I�ɊJ�������@�ł���B���O�̂Ƃ���A���̕����P�ʂ̗��x��3�i�ō\������B1�i�ڂ̕��i��2�i�ڂ��p�����A2�i�ڂ̕��i��3�i�ڂ��p������Ƃ����d�g�݂ɂȂ�B���̕��i�̍쐬�w�j�͈ȉ��̂Ƃ��肾�i��ނƂ��đ�2��ō쐬�����T���v�������p����j�B

�@�܂�1�i���B��2��ɐ��������悤�ɁA�e�R���g���[���ɋ��ʂ��鏈����1�‚̃R���g���[���i��t�H�[���j�Ƀ��b�v���ĕ��i������B�������u���b�p�[�E�R���g���[���i�������̓��b�p�[�E�t�H�[���j�v�i���ʏ����P�ʁj���쐬����B

�@2�i���BSample1SearchControl�R���g���[���i������ʃp�[�c�j�^Sample1ListControl�R���g���[���i�ꗗ��ʃp�[�c�j�^Sample1DetailControl�R���g���[���i�ڍ׉�ʃp�[�c�j�̊�{�@�\�����݂̂���������SearchBaseControl�R���g���[���i�����@�\�j�^ListBaseControl�R���g���[���i�ꗗ�@�\�j�^DetailBaseControl�R���g���[���i�ڍ׋@�\�j�Ȃǂ��u�@�\�R���g���[���v�i���ʋ@�\�P�ʁj���쐬����B���̂Ƃ�1�i�ڂ̃��b�p�[�E�R���g���[�����p������B

�@������3�i���B�����̋@�\�R���g���[�����p������Sample2SearchControl�i������ʃp�[�c�j�^Sample2ListControl�i�ꗗ��ʃp�[�c�j�^Sample2DetailControl�i�ڍ׉�ʃp�[�c�j�Ȃǂ��u���[�U�[�E�R���g���[���v�i��ʃp�[�c�P�ʁj���쐬����B�����̃R���g���[���́A�ŏ���Sample1SearchControl�R���g���[���i������ʃp�[�c�j�^Sample1ListControl�R���g���[���i�ꗗ��ʃp�[�c�j�^Sample1DetailControl�R���g���[���i�ڍ׉�ʃp�[�c�j����@�\�R���g���[���̓��e���������������̂��B

�@�v����ɁASample1SearchControl�R���g���[���i������ʃp�[�c�j�^Sample1ListControl�R���g���[���i�ꗗ��ʃp�[�c�j�^Sample1DetailControl�R���g���[���i�ڍ׉�ʃp�[�c�j���@�\�����Ƃ���ȊO�ɕ������āA�@�\������2�i�ڂɁA����ȊO��3�i�ڂɔz�u����킯���B���̂悤�ɕ������Ă����΁A3�i�ڂŋ@�\����������K�v���Ȃ��Ȃ�A���ʂ̋@�\���J��Ԃ��L�q����K�v���Ȃ��Ȃ�B��ʓI�ł͂Ȃ�����ȋ@�\�������3�i�ڂŎ�������΂悢�B

�@1�‚��ƒR�[�h�����Ă������B

�@1�i�ڂł̓��[�U�[�E�R���g���[���iUserControl�N���X�j���p�����郉�b�p�[�E�R���g���[���Ƃ��āuBaseUserControl�v�N���X�iBaseUserControl.vb�t�@�C���j���쐬����B�����ł́A�������ʂ��鏈�����Ȃ��̂ŁA�R�[�h�͒lj����Ȃ��B

Public Class BaseUserControl
End Class
BaseUserControl�N���X�̃R�[�h���e�iBaseUserControl.vb�t�@�C���j
���[�U�[�E�R���g���[���́m�V�������ڂ̒lj��n�_�C�A���O�ŁA�u���[�U�[ �R���g���[���v�e���v���[�g��I�����č쐬����B�����Ɏ����Ă���R�[�h�ł͕�����Ȃ����A���̍ۂɐ��������BaseUserControl.Desingner.vb�R�[�h�E�r�n�C���h�E�t�@�C���ɁA�uInherits System.Windows.Forms.UserControl�v�Ƃ����L�q�����邽�߁ABaseUserControl�N���X�̓��[�U�[�E�R���g���[�����p�����Ă���B

�@2�i�ڂł́ABaseUserControl�N���X���p�����郆�[�U�[�E�R���g���[���Ƃ��āA

  • SearchBaseControl�R���g���[���i�����@�\�j
  • ListBaseControl�R���g���[���i�ꗗ�@�\�j
  • DetailBaseControl�R���g���[���i�ڍ׋@�\�j

���쐬����B

�@�܂�DetailBaseControl�R���g���[���Ƃ��āA�uDetailBaseControl�v�N���X�iDetailBaseControl.vb�t�@�C���j���쐬����B��̓I�ɂ͈ȉ��̂悤�ȃR�[�h�ɂȂ�B�����ł́uISearchEditByKeysController�v�uISearchEditByKeysTableAdapter�v�Ȃǂ̃C���^�[�t�F�C�X�iInterface�j���g���Ă���̂ŁA�iSearchBaseControl�^ListBaseControl�^DetailBaseControl�R���g���[���ԂŁj�����̋K�i���ėp������Ă��邱�Ƃ������邾�낤�B

Public Class DetailBaseControl

  Private _dataTable As DataTable
  Private _bindingSource As BindingSource
  Private _tableAdapter As ISearchEditByKeysTableAdapter
  Private _controller As ISearchEditByKeysController

  Public Overridable Sub InitializeControl( _
      ByVal controller As ISearchEditByKeysController, _
      ByVal dataTable As DataTable, _
      ByVal bindingSource As BindingSource, _
      ByVal tableAdapter As ISearchEditByKeysTableAdapter)
    _controller = controller
    _dataTable = dataTable
    _bindingSource = bindingSource
    _tableAdapter = tableAdapter
  End Sub

  Public Overridable Function AddNewData() As Object
    Return _controller.AddNew()
  End Function

  Public Overridable Function LoadData(ByVal keys As DataTableKeys) As Boolean
    If keys Is Nothing Then Return AddNewData()
    Return _controller.LoadByKeys(keys)
  End Function

  Public Overridable Function SaveData() As Boolean
    If Not Me.ValidateChildren() Then Return False
    Return _controller.Save()
  End Function

  Public Overridable Function DeleteData() As Boolean
    Dim result As DialogResult = MessageBox.Show(My.Resources.QuestionDelete, Me.ParentForm.Text, MessageBoxButtons.OKCancel)
    If result <> DialogResult.OK Then Return False
    Return _controller.Delete()
  End Function

End Class
DetailBaseControl�N���X�̃R�[�h���e�iDetailBaseControl.vb�t�@�C���j
BaseUserControl�N���X���p�����郆�[�U�[�E�R���g���[�����쐬����ɂ́A�m�V�������ڂ̒lj��n�_�C�A���O�ŁA�u�p�����ꂽ���[�U�[ �R���g���[���v�Ƃ����e���v���[�g��I�сA�t�@�C�������������O�ɕ\�������m�p���s�b�J�[�n�_�C�A���O�ŁuBaseUserControl�v��I������΂悢�B�����Ɏ����Ă���R�[�h�ł͕�����Ȃ����A���̍ۂɐ��������BaseUserControl.Desingner.vb�R�[�h�E�r�n�C���h�E�t�@�C���ɁA�uInherits BaseUserControl�v�Ƃ����L�q�����邽�߁ABaseUserControl�N���X�̓��[�U�[�E�R���g���[�����p�����Ă���B

�@�Ȃ���L�R�[�h��SaveData���\�b�h�ł́A���N���XUserControl��ValidateChildren���\�b�h���Ă�ł���̂ŁA�R���g���[����Validating�C�x���g�E�n���h���œ��̓G���[�E�`�F�b�N�Ȃǂ̌��؏������s����B�������A����ɂ‚��Ă͖{�e�̖ړI�O�Ȃ̂ō���͎������Ă��Ȃ��B

�@�����āAListBaseControl�R���g���[����SearchBaseControl�R���g���[������������B�R�[�h���e�́A���̂悤�ɂȂ�B

Public Class ListBaseControl

  Private _dataGridView As DataGridView
  Private _dataTable As DataTable
  Private _bindingSource As BindingSource
  Private _tableAdapter As ISearchEditByKeysTableAdapter
 Private _controller As ISearchEditByKeysController

  Public Overridable Sub InitializeControl( _
      ByVal controller As ISearchEditByKeysController, _
      ByVal dataGridView As DataGridView, _
      ByVal dataTable As DataTable, _
      ByVal bindingSource As BindingSource, _
      ByVal tableAdapter As ISearchEditByKeysTableAdapter)
    _controller = controller
    _dataGridView = dataGridView
    _dataTable = dataTable
    _bindingSource = bindingSource
    _tableAdapter = tableAdapter
    RebindBindingSource()
  End Sub

  Public Overridable Sub RebindBindingSource()
    _dataGridView.DataSource = _bindingSource
  End Sub

  Public Overridable Function FillTable() As Boolean
    Return _controller.Load()
  End Function

  Public Overridable Function GetCurrentKeys() As DataTableKeys
    Dim row As DataRow = DataGridViewHelper.GetCurrentRow(_dataGridView)
    If row Is Nothing Then Return Nothing
    Return _tableAdapter.GetKeys(row)
  End Function

  Public Overridable Function SearchTable(ByVal condition As SearchConditions) As Boolean
    Return _controller.SearchConditions(condition)
  End Function

End Class
ListBaseControl�N���X�̃R�[�h���e�iListBaseControl.vb�t�@�C���j

Public Class SearchBaseControl

  Public Overridable Sub ClearSearchConditions()
  End Sub

  Public Overridable Function GetSearchConditions() As SearchConditions
    Return Nothing
  End Function

End Class
SearchBaseControl�N���X�̃R�[�h���e�iSearchBaseControl.vb�t�@�C���j

�@SearchBaseControl�R���g���[���i�����@�\�j�Ɋւ��Ă͉�ʂ̍��ڂɈˑ����Ă���̂ŁA2�i�ڂł̓��\�b�h�̘g��������Ă������Ƃɂ���B

�@3�i�ڂł���Sample2ListControl�i�ꗗ��ʃp�[�c�j�^Sample2DetailControl�i�ڍ׉�ʃp�[�c�j�́A�@�\���Ȃ��R�[�h���Ȃ��B

Public Class Sample2DetailControl
End Class
Sample2DetailControl�N���X�̃R�[�h���e�iSample2DetailControl.vb�t�@�C���j
Sample2DetailControl�N���X��DetailBaseControl�N���X���p�����郆�[�U�[�E�R���g���[���ł���B

Public Class Sample2ListControl
End Class
Sample2ListControl�N���X�̃R�[�h���e�iSample2ListControl.vb�t�@�C���j
Sample2ListControl�N���X��ListBaseControl�N���X���p�����郆�[�U�[�E�R���g���[���ł���B

�@Sample1SearchControl�R���g���[���i������ʃp�[�c�j�́A2�i�ڂ�SearchBaseControl�R���g���[�����p�����郆�[�U�[�E�R���g���[�������A����SearchBaseControl�R���g���[���ł̓��\�b�h�̘g�����������Ȃ������̂ŁA�����Ŏ��ۂ̃R�[�h���L�q����B���̂悤�ȃR�[�h�ɂȂ�B

Public Class Sample2SearchControl

  Public Overrides Sub ClearSearchConditions()
    Me.��BaseTextBox.Text = ""
    Me.��BaseTextBox.Text = ""
    Me.���[�U�[��BaseTextBox.Text = ""
  End Sub

  Public Overrides Function GetSearchConditions() As SearchConditions
    Return New ���[�U�[DataSet.���[�U�[SearchConditions( _
        Me.��BaseTextBox.Text, _
        Me.��BaseTextBox.Text, _
        Me.���[�U�[��BaseTextBox.Text)
  End Function

End Class
Sample2SearchControl�N���X�̃R�[�h���e�iSample2SearchControl.vb�t�@�C���j
Sample2SearchControl�N���X��SearchBaseControl�N���X���p�����郆�[�U�[�E�R���g���[���ł���B

�@�������3�i�ڂɂ́A���ۂɂ�Sample1SearchControl�R���g���[���i������ʃp�[�c�j�Ɠ����A�R���g���[����u���[�U�[DataSet�v�u���[�U�[BindingSource�v�u���[�U�[TableAdapter�v�Ƃ��������͔̂z�u����K�v�����邪�A�@�\�I�ɂ�2�i�ڂŎ������Ă���̂Ōp�����Ŏ�������K�v�͂Ȃ��B

3�i�ڂ�Sample2DetailControl���[�U�[�E�R���g���[���ɔz�u����R���g���[���̗�iSample2DetailControl.vb�t�@�C���j

�@�Ō��Windows�t�H�[���Ƃ��āuSample2Form�v�N���X�iSample2Form.vb�t�@�C���j���쐬���A���̃t�H�[�����Sample2SearchControl�i������ʃp�[�c�j�^Sample2ListControl�i�ꗗ��ʃp�[�c�j�^Sample2DetailControl�i�ڍ׉�ʃp�[�c�j��z�u����BSample2Form�N���X�̃R�[�h���e�͈ȉ��̂悤�ɂȂ�B

Public Class Sample2Form

  Private controller As New ���[�U�[Controller

  Private Sub Sample2Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    RebindBindingSource()
    InitializeControls()
    Me.���[�U�[TableAdapter.Fill(Me.���[�U�[DataSet.���[�U�[)
  End Sub

  Private Sub RebindBindingSource()
    Me.���[�U�[DataSet = Me.Sample2DetailControl1.���[�U�[DataSet
    Me.���[�U�[TableAdapter = Me.Sample2DetailControl1.���[�U�[TableAdapter
    Me.���[�U�[BindingSource = Me.Sample2DetailControl1.���[�U�[BindingSource
    Me.���[�U�[BindingNavigator.BindingSource = Me.���[�U�[BindingSource
    Me.Sample2ListControl1.���[�U�[DataSet = Me.���[�U�[DataSet
    Me.Sample2ListControl1.���[�U�[TableAdapter = Me.���[�U�[TableAdapter
    Me.Sample2ListControl1.���[�U�[BindingSource = Me.���[�U�[BindingSource
    Me.Sample2ListControl1.���[�U�[BaseDataGridView.DataSource = Me.���[�U�[BindingSource
  End Sub

  Private Sub InitializeControls()
    Me.Sample2DetailControl1.InitializeControl(controller, Me.���[�U�[DataSet.���[�U�[, Me.���[�U�[BindingSource, Me.���[�U�[TableAdapter)
    Me.Sample2ListControl1.InitializeControl(controller, Me.Sample2ListControl1.���[�U�[BaseDataGridView, Me.���[�U�[DataSet.���[�U�[, Me.���[�U�[BindingSource, Me.���[�U�[TableAdapter)
    Me.Sample2SearchControl1.ClearSearchConditions()
    controller.InitializeController(Me.���[�U�[TableAdapter, Me.���[�U�[BindingSource, Me.���[�U�[DataSet.���[�U�[)
  End Sub

  Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click
    Me.Sample2DetailControl1.AddNewData()
  End Sub

  Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
    Me.Sample2DetailControl1.DeleteData()
  End Sub

  Private Sub ���[�U�[BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ���[�U�[BindingNavigatorSaveItem.Click
    Me.Sample2DetailControl1.SaveData()
  End Sub

  Private Sub SearchToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchToolStripButton.Click
    Me.Sample2ListControl1.SearchTable(Me.Sample2SearchControl1.GetSearchConditions())
  End Sub

End Class
Sample2Form�N���X�̃R�[�h���e�iSample2Form.vb�t�@�C���j

�@�ȏ�Ŋ��������O�i�p�������ۂɎ��������Ƃ��̃N���X�^�I�u�W�F�N�g�\�����ȉ��̉�ʂł���B

�O�i�p�������ۂɎ��������Ƃ��̃N���X�^�I�u�W�F�N�g�\��

�@�ȉ��̕\�͂��̐}���܂Ƃߒ��������̂ł���B�u��ʃp�[�c�P�ʁv�Ƃ͖{���̐����́u��ʃp�[�c�v��\���A�u���ʋ@�\�P�ʁv�́u�@�\�R���g���[���v���A�u���ʏ����P�ʁv�́u���b�p�[�E�R���g���[���i���b�p�[�E�t�H�[���j�v���Ӗ����Ă���B

���[�U�[�E�C���^�[�t�F�C�X 3�i��
�i��ʃp�[�c�P�ʁj
2�i��
�i���ʋ@�\�P�ʁj
1�i��
�i���ʏ����P�ʁj
������� Sample2SearchControl SearchBaseControl BaseUserControl
�ڍ׉�� Sample2DetailControl DetailBaseControl
�ꗗ��� Sample2SearchControl SearchBaseControl
�O�i�p�������ۂɎ��������Ƃ��̃N���X�^�I�u�W�F�N�g�\���̂܂Ƃ�

�@2�i�ڂ̋@�\�R���g���[�����|�C���g�ł���B3�i�ڂ̓��e���A���Ƃ����[�U�[�Ǘ��Ǝ����Ǘ��̂悤�Ɏ�舵���f�[�^�̎�ނ��S�R����Ă����Ƃ��Ă��A�����ɋ��ʂ����@�\������΁i�Ⴆ�΃f�[�^�̒lj��^�X�V�^�폜�Ȃǂ̋@�\�͋��ʉ����₷���j�A�����2�i�ڂŔėp�����Ďg���񂹂�悤�ɂ������B2�i�ڂŃf�[�^�o�C���f�B���O�����i�f�[�^�Z�b�g�^�e�[�u���A�_�v�^�^BindingSource�R���|�[�l���g�j����舵���ɂ́A�u���[�U�[DataSet�^���[�U�[TableAdapter�^���[�U�[BindingSource�v�ł͂Ȃ��A�uDataSet�^TableAdapter�^BindingSource�v�ȂNJ�{�^�𗘗p����K�v������B


�@INDEX
�@ ���H�Ŗ𗧂‹Ɩ��A�v���J���̃q���g
�@ ��4�� �K�؂ȗ��x�Ń��C�u���������ĊJ�����Y�ɂ���
  1�D�J���q���g9�F�O�i�p��
�@   2�D�J���q���g10�F�t�H���_�ƃv���W�F�N�g�Ő���

CfbNXEy[Ww �@�u���H�Ŗ𗧂‹Ɩ��A�v���J���̃q���g�v


Insider.NET �t�H�[���� �V���L��
  • ��2��@�Ȍ��ȃR�[�f�B���O�̂��߂� �i2017/7/26�j
    �@�����_���ŋL�q�ł��郁���o�̑����Athrow���Aout�ϐ��A�^�v���ȂǁAC# 7�ɂ͈ȑO�����R�[�h���Ȍ��ɋL�q�ł���悤�ȋ@�\����������Ă���
  • ��1��@Visual Studio Code�f�o�b�O�̊�b�m�� �i2017/7/21�j
    �@Node.js�v���O�������f�o�b�O���Ȃ���AVisual Studio Code�ɓ�������Ă���f�o�b�O�@�\�̊�{�́u�L�v���}�X�^�[���悤
  • ��1��@���ĂȃR�[�f�B���O�̂��߂� �i2017/7/19�j
    �@C# 7�Œlj����ꂽ�V�@�\�̒�����A�u���l���e�����\���̉��P�v�Ɓu���[�J���֐��v���Љ��B�����͕�����₷���R�[�h���L�q����̂Ɏg����
  • Presentation Translator �i2017/7/18�j
    �@Presentation Translator��PowerPoint�p�̃A�h�C���B�v���[���e�[�V�������̎����̕t����A������ł̎��^�����A�X���C�h�̖|����s����
��IT���[���}�K�W���@�V������X�^�b�t�̃R���������[���œ͂��܂��i�����j
- PR -

���ڂ̃e�[�}

�Ɩ��A�v��Insider �L�������L���O

�{�� ����
�\�����[�V����FLASH
"); adremove.push(adstrtmp[adstart]); } } for(var i = 0; i < adremove.length; i++){ adremove[i].parentNode.removeChild(adremove[i]); } adstr.sort().reverse(); adstr = adstr.join(""); return adstr; }