Re: DataGrid - Row Height?
A DataRow is a row of data in a DataTable. It isn't going to have a Height property because it is not a UI element. My guess is that, like many other controls, the height of a row in a DataGrid is automatically set relative to the size of the Font used. You'd probably have to draw all or part of the DataGrid yourself to control the row height. That's not definitive mind you. If it can be done I'd guess you'd find out how from the Windows Forms FAQ link in my sig, which has heaps of information on using the DataGrid and many other controls.
Re: DataGrid - Row Height?
I don't know what you mean by it not being a UI element. The user can quite easilly adjust the row height of individual rows.
In addition, there is a PreferredRowHeight property of both the DataGrid and the TableStyle objects that controls the default row height.
However I'll check out that link in your sig anyway...
p.s. that's one hell of a sig!
Re: DataGrid - Row Height?
You can try looking into DataGridColumnStyles, I believe if you do it correctly you can specify the row heights, however I was unable to do it a while back when trying, so I am not 100% sure...
Re: DataGrid - Row Height?
Quote:
Originally Posted by simonm
I don't know what you mean by it not being a UI element. The user can quite easilly adjust the row height of individual rows.
In addition, there is a PreferredRowHeight property of both the DataGrid and the TableStyle objects that controls the default row height.
However I'll check out that link in your sig anyway...
p.s. that's one hell of a sig!
You need to distinguish between a row in your DataGrid and a row in your DataTable. In the code you posted the "drTarget" variable is a DataRow, which is not a UI element. You don't have to display a DataRow in a DataGrid so why should the DataRow object have property that controls the height of a row in a DataGrid? That's like saying that the String class should have a property that controls the height of a TextBox. As for the PreferredRowHeight, that is for the entire grid. I assumed that you wanted to affect individual rows, but perhaps not. The help topic for that property also states that you have to set it before assigning a DataSource, so you'd have to re-assign an existing DataSource for it to have an effect.
Re: DataGrid - Row Height?
Yes, I do want to affect individual rows. And I am perfectly willing to accept that I am going down the wrong path looking at datarows of datatables.
But I see no way of getting to the rows of the datagrid either. :sick:
Re: DataGrid - Row Height?
I don't think there is supposed to be a way. The PreferredRowHeight presumably sets the default height of all rows and individual rows will be taller if the data they are displaying requires it. That's why I said previously that you would probably have to draw the grid yourself, which is bound to be an enormous hassle. You could look around for a third-party component that already provides that functionality.
Re: DataGrid - Row Height?
As I have said, the user can quite easilly adjust the row heights manually. But the rows do not automatically expand to fit the contents of the cells (specifically when the text is on multiple lines in one cell). It would seem to me to be a enormous oversight for there to be lacking a programatic interface to access this when it is a part of the UI.
Re: DataGrid - Row Height?
Quote:
Originally Posted by simonm
As I have said, the user can quite easilly adjust the row heights manually.
Is that so? I thought you meant that you wanted to be able to do that but couldn't. I haven't used DataGrids much at all myself so I wasn't aware of that. It doesn't help you much but it seems that you can access the rows of the grid directly in the new DataGridView as there is a DataGridViewRow class that has a Height property.