471,627 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

DataGridViewRow.Height

Hi,

I want to make row higher when it is seleceted. See following code:

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

List<Item> items = new List<Item>();
for (int i = 0; i < 100; i++)
{
items.Add(new Item());
}

itemDataGridView.SelectionMode =
DataGridViewSelectionMode.FullRowSelect;
itemBindingSource.DataSource = items;
this.itemDataGridView.SelectionChanged += new
EventHandler(itemDataGridView_SelectionChanged);
}

// this method calls one time during form loading, but all rows
have Height = 50
void itemDataGridView_SelectionChanged(object sender, EventArgs
e)
{
if (itemDataGridView.SelectedRows.Count == 1)
{
itemDataGridView.SelectedRows[0].Height = 50;
}
}
}

But after form is loaded ALL ROWS have height = 50. Handler
itemDataGridView_SelectionChanged called only one time during loading.
So what I'm doing wrong?

Feb 16 '06 #1
1 1892
Hi Yury,

Basically, in the class constructor, you are binding and attaching an
event handler, right?
'Handler
itemDataGridView_SelectionChanged called only one time during loading.
' > How is selection_Changed raised when loading? It is supposed to be
called only when the selected index changes. Are you modifying the
selected index in Form_Load or somewhere else?

Also, I think you should add code in itemDataGridView_SelectionChanged
to reset the height of the previously selected row. Otherwise, once you
have selected a row, it's height will remain 50.

Regards,

Jim

Feb 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Robert Bravery | last post: by
1 post views Thread by daokfella | last post: by
6 posts views Thread by doomsday123 | last post: by
reply views Thread by =?Utf-8?B?Q2xhdWRl?= | last post: by
1 post views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.