By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,481 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,481 IT Pros & Developers. It's quick & easy.

Fixed number of rows in a datagrid

P: n/a
If I have a datagrid and the bound data file only have 4 rows in it, the
grid will show the 4 rows. However, there is blank space below that
until it reaches the bottom of the grid. Is there a way to have a fixed
number of rows regardless of what data is in the bound table?

Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Hi,

To prevent the user from adding a new row set the
dataset.datatables.defaultview.allownew = false.

http://msdn.microsoft.com/library/de...ownewtopic.asp
Ken
---------------------
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:7B*****************@newssvr16.news.prodigy.co m...
If I have a datagrid and the bound data file only have 4 rows in it, the
grid will show the 4 rows. However, there is blank space below that
until it reaches the bottom of the grid. Is there a way to have a fixed
number of rows regardless of what data is in the bound table?

Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #2

P: n/a
Hi,

To prevent the user from adding a new row set the
dataset.datatables.defaultview.allownew = false.

http://msdn.microsoft.com/library/de...ownewtopic.asp
Ken
---------------------
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:7B*****************@newssvr16.news.prodigy.co m...
If I have a datagrid and the bound data file only have 4 rows in it, the
grid will show the 4 rows. However, there is blank space below that
until it reaches the bottom of the grid. Is there a way to have a fixed
number of rows regardless of what data is in the bound table?

Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #3

P: n/a
Actually, I don't want to prevent them from adding a new row. I have a
grid that is about 6 inches long, and with only 3 rows of data more than
half of the grid window is blank with no rows. I want that whole area to
look like the grid. I can't really think of a good way to explain it...
If a grid can have up to 10 lines before scrolling, I want all 10 lines
to be there whether there is data or not...

Ken Tucker [MVP] wrote:
Hi,

To prevent the user from adding a new row set the
dataset.datatables.defaultview.allownew = false.

http://msdn.microsoft.com/library/de...ownewtopic.asp
Ken
---------------------
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:7B*****************@newssvr16.news.prodigy.co m...
If I have a datagrid and the bound data file only have 4 rows in it, the
grid will show the 4 rows. However, there is blank space below that
until it reaches the bottom of the grid. Is there a way to have a fixed
number of rows regardless of what data is in the bound table?

Thanks,
Aaron

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #4

P: n/a
Actually, I don't want to prevent them from adding a new row. I have a
grid that is about 6 inches long, and with only 3 rows of data more than
half of the grid window is blank with no rows. I want that whole area to
look like the grid. I can't really think of a good way to explain it...
If a grid can have up to 10 lines before scrolling, I want all 10 lines
to be there whether there is data or not...

Ken Tucker [MVP] wrote:
Hi,

To prevent the user from adding a new row set the
dataset.datatables.defaultview.allownew = false.

http://msdn.microsoft.com/library/de...ownewtopic.asp
Ken
---------------------
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:7B*****************@newssvr16.news.prodigy.co m...
If I have a datagrid and the bound data file only have 4 rows in it, the
grid will show the 4 rows. However, there is blank space below that
until it reaches the bottom of the grid. Is there a way to have a fixed
number of rows regardless of what data is in the bound table?

Thanks,
Aaron

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #5

P: n/a
I don't think you can do that with the datagrid that comes with VB.NET. If I understand you right you want to have a grid drawn
on the screen that has , say 10 rows(with columns) visible, even if there is only 3 of those rows populated with data. Is that
right?
With the regular datagrid, I believe you can only have one extra row visible(that is if you have Allow Edit enabled) and it is
to allow your user to input new data. I think you will have to draw your own datagrid to do what you are wanting to do.
I really don't understand why you would want to do that anyway. That is not common practice with most applications that use a
datagrid to display data and allow editing. Besides, think about this, if you did have it that way, then your user could skip a
row and insert a blank row into the database. Personally, I don't want that to happen.
Well, that's my .02 and it is only my opinion. Good luck on finding a fix to what you are wanting to do.
james
"Aaron Smith" <th**********@smithcentral.net> wrote in message news:wd*****************@newssvr16.news.prodigy.co m...
Actually, I don't want to prevent them from adding a new row. I have a grid that is about 6 inches long, and with only 3 rows
of data more than half of the grid window is blank with no rows. I want that whole area to look like the grid. I can't really
think of a good way to explain it... If a grid can have up to 10 lines before scrolling, I want all 10 lines to be there
whether there is data or not...

Ken Tucker [MVP] wrote:
Hi,

To prevent the user from adding a new row set the
dataset.datatables.defaultview.allownew = false.

http://msdn.microsoft.com/library/de...ownewtopic.asp
Ken
---------------------
"Aaron Smith" <th**********@smithcentral.net> wrote in message news:7B*****************@newssvr16.news.prodigy.co m...
If I have a datagrid and the bound data file only have 4 rows in it, the
grid will show the 4 rows. However, there is blank space below that
until it reaches the bottom of the grid. Is there a way to have a fixed
number of rows regardless of what data is in the bound table?

Thanks,
Aaron

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #6

P: n/a
I don't think you can do that with the datagrid that comes with VB.NET. If I understand you right you want to have a grid drawn
on the screen that has , say 10 rows(with columns) visible, even if there is only 3 of those rows populated with data. Is that
right?
With the regular datagrid, I believe you can only have one extra row visible(that is if you have Allow Edit enabled) and it is
to allow your user to input new data. I think you will have to draw your own datagrid to do what you are wanting to do.
I really don't understand why you would want to do that anyway. That is not common practice with most applications that use a
datagrid to display data and allow editing. Besides, think about this, if you did have it that way, then your user could skip a
row and insert a blank row into the database. Personally, I don't want that to happen.
Well, that's my .02 and it is only my opinion. Good luck on finding a fix to what you are wanting to do.
james
"Aaron Smith" <th**********@smithcentral.net> wrote in message news:wd*****************@newssvr16.news.prodigy.co m...
Actually, I don't want to prevent them from adding a new row. I have a grid that is about 6 inches long, and with only 3 rows
of data more than half of the grid window is blank with no rows. I want that whole area to look like the grid. I can't really
think of a good way to explain it... If a grid can have up to 10 lines before scrolling, I want all 10 lines to be there
whether there is data or not...

Ken Tucker [MVP] wrote:
Hi,

To prevent the user from adding a new row set the
dataset.datatables.defaultview.allownew = false.

http://msdn.microsoft.com/library/de...ownewtopic.asp
Ken
---------------------
"Aaron Smith" <th**********@smithcentral.net> wrote in message news:7B*****************@newssvr16.news.prodigy.co m...
If I have a datagrid and the bound data file only have 4 rows in it, the
grid will show the 4 rows. However, there is blank space below that
until it reaches the bottom of the grid. Is there a way to have a fixed
number of rows regardless of what data is in the bound table?

Thanks,
Aaron

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #7

P: n/a
Thanks for the repsonse James. You have the idea of what I want exactly
right. I know this is not standard. The problem is, we are converting
software over to VB.Net that was written in another language. In that
language, they had the grid as I explained. My employer wanted to
recreate that. If there is no way to do it, then so be it, I'm not going
to go through the work of rolling my own datagrid just to have that
happen. The way the other language would work, is you had the grid and
you could not navigate to the other rows if they were blank. You could
only go to the one row following the last row of data, so that you could
enter in a new row.

Thanks again,
Aaron

james wrote:
I don't think you can do that with the datagrid that comes with VB.NET. If I understand you right you want to have a grid drawn
on the screen that has , say 10 rows(with columns) visible, even if there is only 3 of those rows populated with data. Is that
right?
With the regular datagrid, I believe you can only have one extra row visible(that is if you have Allow Edit enabled) and it is
to allow your user to input new data. I think you will have to draw your own datagrid to do what you are wanting to do.
I really don't understand why you would want to do that anyway. That is not common practice with most applications that use a
datagrid to display data and allow editing. Besides, think about this, if you did have it that way, then your user could skip a
row and insert a blank row into the database. Personally, I don't want that to happen.
Well, that's my .02 and it is only my opinion. Good luck on finding a fix to what you are wanting to do.
james
"Aaron Smith" <th**********@smithcentral.net> wrote in message news:wd*****************@newssvr16.news.prodigy.co m...
Actually, I don't want to prevent them from adding a new row. I have a grid that is about 6 inches long, and with only 3 rows
of data more than half of the grid window is blank with no rows. I want that whole area to look like the grid. I can't really
think of a good way to explain it... If a grid can have up to 10 lines before scrolling, I want all 10 lines to be there
whether there is data or not...

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #8

P: n/a
Thanks for the repsonse James. You have the idea of what I want exactly
right. I know this is not standard. The problem is, we are converting
software over to VB.Net that was written in another language. In that
language, they had the grid as I explained. My employer wanted to
recreate that. If there is no way to do it, then so be it, I'm not going
to go through the work of rolling my own datagrid just to have that
happen. The way the other language would work, is you had the grid and
you could not navigate to the other rows if they were blank. You could
only go to the one row following the last row of data, so that you could
enter in a new row.

Thanks again,
Aaron

james wrote:
I don't think you can do that with the datagrid that comes with VB.NET. If I understand you right you want to have a grid drawn
on the screen that has , say 10 rows(with columns) visible, even if there is only 3 of those rows populated with data. Is that
right?
With the regular datagrid, I believe you can only have one extra row visible(that is if you have Allow Edit enabled) and it is
to allow your user to input new data. I think you will have to draw your own datagrid to do what you are wanting to do.
I really don't understand why you would want to do that anyway. That is not common practice with most applications that use a
datagrid to display data and allow editing. Besides, think about this, if you did have it that way, then your user could skip a
row and insert a blank row into the database. Personally, I don't want that to happen.
Well, that's my .02 and it is only my opinion. Good luck on finding a fix to what you are wanting to do.
james
"Aaron Smith" <th**********@smithcentral.net> wrote in message news:wd*****************@newssvr16.news.prodigy.co m...
Actually, I don't want to prevent them from adding a new row. I have a grid that is about 6 inches long, and with only 3 rows
of data more than half of the grid window is blank with no rows. I want that whole area to look like the grid. I can't really
think of a good way to explain it... If a grid can have up to 10 lines before scrolling, I want all 10 lines to be there
whether there is data or not...

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #9

P: n/a
Your welcome Aaron. The one thing I did think of is, you could append empty rows with null values in each cell at the end of the
actual rows that hold data and then set Edit to the first empty row with the null values. But, I think that would end up
getting pretty messy. You would have to set the display of the grid in such a way that the grid would never show more than 10
rows (empty or not) and if there were any rows without actual data in them, then append as many empty rows as needed to make up
the difference.
Then each time your user added new data to the empty rows, till it filled the 10 row limit, have them scroll and then re-append
more empty rows as needed. See what I mean? It would be a mess keeping track of all that. I would show your boss the new way to
do things and let him see how nice that can be.
james

"Aaron Smith" <th**********@smithcentral.net> wrote in message news:Dv*****************@newssvr16.news.prodigy.co m...
Thanks for the repsonse James. You have the idea of what I want exactly right. I know this is not standard. The problem is, we
are converting software over to VB.Net that was written in another language. In that language, they had the grid as I
explained. My employer wanted to recreate that. If there is no way to do it, then so be it, I'm not going to go through the
work of rolling my own datagrid just to have that happen. The way the other language would work, is you had the grid and you
could not navigate to the other rows if they were blank. You could only go to the one row following the last row of data, so
that you could enter in a new row.

Thanks again,
Aaron

james wrote:
I don't think you can do that with the datagrid that comes with VB.NET. If I understand you right you want to have a grid
drawn on the screen that has , say 10 rows(with columns) visible, even if there is only 3 of those rows populated with data.
Is that right?
With the regular datagrid, I believe you can only have one extra row visible(that is if you have Allow Edit enabled) and it
is to allow your user to input new data. I think you will have to draw your own datagrid to do what you are wanting to do.
I really don't understand why you would want to do that anyway. That is not common practice with most applications that use a
datagrid to display data and allow editing. Besides, think about this, if you did have it that way, then your user could
skip a row and insert a blank row into the database. Personally, I don't want that to happen.
Well, that's my .02 and it is only my opinion. Good luck on finding a fix to what you are wanting to do.
james
"Aaron Smith" <th**********@smithcentral.net> wrote in message news:wd*****************@newssvr16.news.prodigy.co m...
Actually, I don't want to prevent them from adding a new row. I have a grid that is about 6 inches long, and with only 3 rows
of data more than half of the grid window is blank with no rows. I want that whole area to look like the grid. I can't really
think of a good way to explain it... If a grid can have up to 10 lines before scrolling, I want all 10 lines to be there
whether there is data or not...

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #10

P: n/a
Your welcome Aaron. The one thing I did think of is, you could append empty rows with null values in each cell at the end of the
actual rows that hold data and then set Edit to the first empty row with the null values. But, I think that would end up
getting pretty messy. You would have to set the display of the grid in such a way that the grid would never show more than 10
rows (empty or not) and if there were any rows without actual data in them, then append as many empty rows as needed to make up
the difference.
Then each time your user added new data to the empty rows, till it filled the 10 row limit, have them scroll and then re-append
more empty rows as needed. See what I mean? It would be a mess keeping track of all that. I would show your boss the new way to
do things and let him see how nice that can be.
james

"Aaron Smith" <th**********@smithcentral.net> wrote in message news:Dv*****************@newssvr16.news.prodigy.co m...
Thanks for the repsonse James. You have the idea of what I want exactly right. I know this is not standard. The problem is, we
are converting software over to VB.Net that was written in another language. In that language, they had the grid as I
explained. My employer wanted to recreate that. If there is no way to do it, then so be it, I'm not going to go through the
work of rolling my own datagrid just to have that happen. The way the other language would work, is you had the grid and you
could not navigate to the other rows if they were blank. You could only go to the one row following the last row of data, so
that you could enter in a new row.

Thanks again,
Aaron

james wrote:
I don't think you can do that with the datagrid that comes with VB.NET. If I understand you right you want to have a grid
drawn on the screen that has , say 10 rows(with columns) visible, even if there is only 3 of those rows populated with data.
Is that right?
With the regular datagrid, I believe you can only have one extra row visible(that is if you have Allow Edit enabled) and it
is to allow your user to input new data. I think you will have to draw your own datagrid to do what you are wanting to do.
I really don't understand why you would want to do that anyway. That is not common practice with most applications that use a
datagrid to display data and allow editing. Besides, think about this, if you did have it that way, then your user could
skip a row and insert a blank row into the database. Personally, I don't want that to happen.
Well, that's my .02 and it is only my opinion. Good luck on finding a fix to what you are wanting to do.
james
"Aaron Smith" <th**********@smithcentral.net> wrote in message news:wd*****************@newssvr16.news.prodigy.co m...
Actually, I don't want to prevent them from adding a new row. I have a grid that is about 6 inches long, and with only 3 rows
of data more than half of the grid window is blank with no rows. I want that whole area to look like the grid. I can't really
think of a good way to explain it... If a grid can have up to 10 lines before scrolling, I want all 10 lines to be there
whether there is data or not...

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.