Altering Controls at run time

JDT_71

Member
Joined
Jul 11, 2006
Messages
7
Programming Experience
Beginner
I have been having trouble changing the Row Height of a dataGrid programatically at run-time. Can this be done? If so, how?

I have also been having trouble changing the Font Size of a Button at run-time. It tells me that it is a Read-Only Property. Is there a way around this? If so, how?
 
Well for the button font one, you have to specify a new font object using the same parameters except the ones you wish to change...

For example to change the font size of a button called button1 from the button click of a button called button2, all you need is this....


VB.NET:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Button1.Font = New Font(Button1.Font.Name, 16, Button1.Font.Style, GraphicsUnit.Pixel)
End Sub
 
JDT_71, you platform is .Net 2 but you ask about DataGrid, sure about that? or are you using the .Net 2 DataGridView? Also please post unrelated questions in separate threads as things tend to get ugly forumwise when people are discussing different topics in same thread, thank you.

With DataGridView you set row height with DGV.RowTemplate.Height property.

With DataGrid there exist no property for this, rows will adjust to the DataGrid font size. There is one solution offered by Syncfusions Windows Forms FAQ at http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q1075q navigate to 5.1. It's not been tested by me, but it's quite a reliable source.
 
Back
Top