Profile Picture

Dynamic rowheight of NlistView...is it possible?

Posted By jody cummings 15 Years Ago
Author
Message
Angel Chorbadzhiev
Posted 15 Years Ago
View Quick Profile
Supreme Being

Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)

Group: Forum Members
Last Active: Last Month
Posts: 139, Visits: 184

Hi Jody,

On vb the code should looks like this:

Dim r As Rectangle = nListView1(0).Bounds

Dim items As Integer = r.Height * (nListView1.Items.Count +1)

Dim size As Size = New Size(nListView1.Width, items + nListView1.HeaderHeight)

nListView1.Size = size

Regards,

Angel.



jody cummings
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 15 Years Ago
Posts: 7, Visits: 1

Hi Angel

I forgot to mention i am working in VB.  Will the code still be similiar?



Angel Chorbadzhiev
Posted 15 Years Ago
View Quick Profile
Supreme Being

Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)

Group: Forum Members
Last Active: Last Month
Posts: 139, Visits: 184

Hi Jody,

In this case you will need to setup the Size property of the NListView control.

The value of the height should be the height of the items multiply to the number of the items plus one, and also you will need to add the height of the header.

The above apply if the control is in Details view, because otherwise the items may resizes in multiple columns.

Here is the code sample:

Rectangle r = nListView1.Items[0].Bounds;

int items = r.Height * (nListView1.Items.Count + 1);

Size size = new Size(nListView1.Width, items + nListView1.HeaderHeight);

nListView1.Size = size;

 

Regards,

Angel.

 



jody cummings
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 15 Years Ago
Posts: 7, Visits: 1

Hi Angel

I do not think i came across clearly so trying again.

I have a NlistView that could contain any number of rows.

To start with i have the NlistView's height fairly small.  You could only see 2 rows of data before having to scroll to see the rest.

So now we run my program and it adds 7 items to the NlistView.  I want to know if i can adjust the height of the whole NlistView so that the users would not have to scroll to see everything that is in the NlistView.

The main reason i want this is i am going to be printing the form that this NlistView will be on and i want everything to show up in the printout.

Maybe this is the wrong control for what i will be doing but i liked the nice formatting of columns in the Nlistview so i chose it to use.

I will end up with probably 5 NListviews containing different data on this form....so maybe tell me if i am going about this wrong now 

Hopefully this is clearer now.

Thank you Angel



Angel Chorbadzhiev
Posted 15 Years Ago
View Quick Profile
Supreme Being

Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)Supreme Being (142 reputation)

Group: Forum Members
Last Active: Last Month
Posts: 139, Visits: 184

Hi Jody,

I guess you are asking about the height of each row not for the whole control.

Basicaly the row height depends from a font size that is set for the control (not for each row).

When you add data into the view you can check the size of the font of that data and if is greater than font size of the control you can set the control's font size to the greter one.

I hope I understand your question correctly in order to give you adequate answer.

 

Regards,

Angel.

 



jody cummings
Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 15 Years Ago
Posts: 7, Visits: 1

I have been trying to figure out a way to make the height of the NlistView dynamic.  the data going into the NListView is dynamic.

Is this possible or am i out of luck?

Jody

 

p.s. your controls are awesome.





Similar Topics


Reading This Topic