Hi Mark,
Thanks for contacting Syncfusion products.
You can achieve you requirement to display rows in the DataGrid based on the number entered in a textbox by handing SfDataGrid.QueryRowHeight event and the TextChanged event of the TextBox as shown in the following code example.
Code example :
|
this.textBox1.TextChanged += TextBox1_TextChanged;
this.sfDataGrid1.QueryRowHeight += SfDataGrid1_QueryRowHeight;
private void TextBox1_TextChanged(object sender, EventArgs e)
{
//Resets the height for all rows in View.
this.sfDataGrid1.TableControl.RowHeightManager.Reset();
this.sfDataGrid1.TableControl.Invalidate();
}
private void SfDataGrid1_QueryRowHeight(object sender, Syncfusion.WinForms.DataGrid.Events.QueryRowHeightEventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text))
{
e.Height = 21;
e.Handled = true;
return;
}
var value = int.Parse(textBox1.Text);
if (value > 0 && e.RowIndex >= value + 1)
e.Height = 0;
else
e.Height = 21;
e.Handled = true;
} |
We have prepared a sample using the above given code example and it is available in the following link for your reference.
Please let us know if you require further assistance from us.
Regards,
Mohanram A.