2017-06-19 8 views
1

私のプログラムは現在、ツリービューを含むポップアップウィンドウにリンクするデータグリッドビューが含まれています。ユーザー選択を返す関数があり、この選択をボタンに表示したいと思います。表示するユーザ選択

これを行う方法に関するアイデアはありますか?私はそうすることができる財産を見つけることができません。 「ツリービューを含むポップアップウィンドウにリンクするデータグリッドビュー」

おかげ

答えて

0

- セル(ボタン)がクリックされたときに、ポップアップウィンドウがそれのツリービューで表示されます。ツリービューの文字列は、ツリービューのユーザによって選択され、ポップアップウィンドウにパブリックプロパティとして保存されます。閉じると、ポップアップウィンドウから文字列が取得され、ボタンのTextが文字列に設定されます。

これは私の質問の解釈です。

ボタンに関するより詳細な情報がわからない場合、ボタンはDataGridViewButtonColumnのメンバーであると見なされます。あなたはボタンコマンド名を与えることができます

void ClassForm_Load(object sender, EventArgs e) 
    { 
     datagridview1.CellMouseDown -= MouseClick; 
     datagridview1.CellMouseDown += MouseClick; 
    } 

    void MouseClick(object sender, DataGridViewCellEventArgs e) 
    { 
     DataGridView dgv = sender as DataGridView; 
     if(dgv == null) return; 

     DataGridViewButtonCell b = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewButtonCell; 
     if (b != null) 
     { 
      MyPopupTreeWindow myPopupTreeWindow = new MyPopupTreeWindow(optional information from button); 
      myPopupTreeWindow.ShowDialog(); 
      string userSelectedString = myPopupTreeWindow.userSelectedString; 
      datagridview1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = userSelectedString; 
     } 
    } 
0

はその後 GridViewのは

<asp:GridView ID="DataGridView" runat="server" AutoGenerateColumns="False" OnRowCommand="DataGridView_RowCommand"> 
     <Columns> 
      <asp:BoundField NullDisplayText="N/A" /> 
      <asp:TemplateField> 
       <ItemTemplate> 
        &nbsp;<asp:LinkButton ID="LinkButton1" runat="server" CommandName="yourCommandName">LinkButton</asp:LinkButton> 
       </ItemTemplate> 
      </asp:TemplateField> 
     </Columns> 
    </asp:GridView> 


protected void DataGridView_RowCommand(object sender, GridViewCommandEventArgs e) 
    {  
      if (e.CommandName == "yourCommandName") 
       { 
       //Do something here 
       } 
    } 
をrowcommand
関連する問題