C#はかなり新しいので、単純なものが見つからない場合や、これを間違った方法で実行しようとしている場合は、ご容赦ください。
メインフォームを補完する別のフォームを作成しています。2番目のフォームのボタンクリックでメインフォームから情報の一部を取得する必要があります。メインの情報は、チェックボックスとテキストボックスに保存されます。
テキストボックスは正常に機能していますが、チェックボックスのタグデータをフォーマットとともにプルする方法がわかりません。チェックボックスデータを持ち込む方法がわからないことを除いて、メインフォームはそのまま正常に動作しています。
これは、メインフォームにチェックボックスのTAGデータを表示するために現在使用しているコードです。
//Statements to write checkboxes to stringbuilder
string checkBoxesLine = "\u2022 LIGHTS ";
foreach (Control control in pnlCheckBoxes.Controls)
{
if (control is CheckBox)
{
CheckBox checkBox = (CheckBox)control;
if (checkBox.Checked && checkBox.Tag is string)
{
string checkBoxId = (string)checkBox.Tag;
checkBoxesLine += string.Format("{0}, ", checkBoxId);
}
}
}
これは、新しいフォームを開き、チェックボックスタグデータとtextbox.textデータを新しいフォームに移動するために使用しているボタンです。
private void code_blue_link_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
trouble_shooting = tshooting_text.Text;
services_offered = services_offered_text.Text;
other_notes = other_notes_text.Text;
cust_modem = cust_modem_text.Text;
//Opens CODE BLUE form and pushes text to it.
code_blue_form CBForm = new code_blue_form();
CBForm.cust_name_cb = cust_name_text.Text;
CBForm.cust_cbr_cb = cust_callback_text.Text;
CBForm.cust_wtn_cb = cust_btn_text.Text;
CBForm.cust_notes_cb = cust_modem + "\r\n" + trouble_shooting + "\r\n" + services_offered + "\r\n" + other_notes;
CBForm.Show();
}
2番目のフォームのコードと、そのフォームのテキストボックスに入力するための情報を取得する方法を次に示します。
public partial class code_blue_form : Form
{
public string cust_name_cb;
public string cust_wtn_cb;
public string cust_cbr_cb;
public string cust_notes_cb;
public string cust_modem_cb;
public code_blue_form()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
cb_name_text.Text = cust_name_cb;
cb_wtn_text.Text = cust_wtn_cb;
cb_cbr_text.Text = cust_cbr_cb;
cb_notes_text.Text = cust_notes_cb;
}
}
}
長い投稿はご容赦ください!これに関するアイデア/方向性をいただければ幸いです。ありがとう!