I'm creating 3 textbox and add to the flowlayoutpanel, but flowlayoutpanel control count 0.Why does the number of checks appear to be 0, what is the reason?
internal void Create_TextBox_Click(object sender, EventArgs e)
{
var Dynamic = sender as TextBox;
Regex regex = new Regex(@"\d+");
Match match = regex.Match(Dynamic.Name);
if (match.Success)
{
if(Dynamic.Name == "txtCash"+match.Value)
{
TextBox DynamicDataOne = fp.Controls.Find("txt" + match.Value, true)[0] as TextBox;
TextBox DynamicDataTwo = fp.Controls.Find("txtTwo" + match.Value, true)[0] as TextBox;
int _One;
int _Two;
if (int.TryParse(DynamicDataOne.Text, out _One) && int.TryParse(DynamicDataTwo.Text, out _Two))
Dynamic.Text = (_One * _Two).ToString();
}
}
}
you can easily do this like:
var textboxes = fp.Controls.OfType<TextBox>().Where(x=> Regex.IsMatch(x.Name, "txtCash\\d+"));