473,395 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

DataGridView visible cells

I am looking for advice/code to assist in determining which cells are
visible on a DGV. The code below works but wanted to see if there are better
methods or perhaps the code below has issues I have not thought about.

Thanks,
Kevin
Dim x As Integer = 0
While x < dataGridView1.Rows.Count
Dim y As Integer = 0
While y < dataGridView1.Rows(x).Cells.Count
Dim c As DataGridViewCell = dataGridView1.Rows(x).Cells(y)
If c.Displayed Then
If Not c.Value Is DBNull.Value Or Nothing Then
Console.WriteLine("Row={0} Value={1}", x.ToString,
dataGridView1.Rows(x).Cells(0).Value)
End If
End If
System.Math.Min(System.Threading.Interlocked.Incre ment(y), y -
1)
End While
System.Math.Min(System.Threading.Interlocked.Incre ment(x), x - 1)
End While
Jun 19 '07 #1
1 5731
Okay I believe this is best

''' <summary>
''' Used to get displayed data on a DataGridView
''' </summary>
''' <param name="GridView">Grid to get data from</param>
''' <param name="PartialRow">Display partial rows or not</param>
''' <param name="Partialcolumn">Display partial columns or not</param>
''' <remarks></remarks>
Sub GetGridViewDisplayedCells(ByVal GridView As
Windows.Forms.DataGridView, Optional ByVal PartialRow As Boolean = False,
Optional ByVal Partialcolumn As Boolean = False)
Dim intRowIndex As Integer = GridView.FirstDisplayedScrollingRowIndex

While intRowIndex < GridView.DisplayedRowCount(PartialRow)
Dim intColumnIndex As Integer = 0
While intColumnIndex < GridView.DisplayedColumnCount(Partialcolumn)
Dim CurrentCell As DataGridViewCell =
GridView.Rows(intRowIndex).Cells(intColumnIndex)
If Not CurrentCell.Value Is DBNull.Value Or Nothing Then
' do what we came for
End If
System.Math.Min(System.Threading.Interlocked.Incre ment(intColumnIndex),
intColumnIndex - 1)
End While
System.Math.Min(System.Threading.Interlocked.Incre ment(intRowIndex),
intRowIndex - 1)
End While
End Sub
"Kevin S Gallagher" <ke***************@state.or.uswrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I am looking for advice/code to assist in determining which cells are
visible on a DGV. The code below works but wanted to see if there are
better methods or perhaps the code below has issues I have not thought
about.

Thanks,
Kevin
Dim x As Integer = 0
While x < dataGridView1.Rows.Count
Dim y As Integer = 0
While y < dataGridView1.Rows(x).Cells.Count
Dim c As DataGridViewCell = dataGridView1.Rows(x).Cells(y)
If c.Displayed Then
If Not c.Value Is DBNull.Value Or Nothing Then
Console.WriteLine("Row={0} Value={1}", x.ToString,
dataGridView1.Rows(x).Cells(0).Value)
End If
End If
System.Math.Min(System.Threading.Interlocked.Incre ment(y), y -
1)
End While
System.Math.Min(System.Threading.Interlocked.Incre ment(x), x - 1)
End While

Jun 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Crazy Cat | last post by:
Hi, I've posted on this before, but was unable to get help. I really would like to use this control, but I can't offer it to my users until I am able to resolve this problem. I am creating...
2
by: Rich | last post by:
Hello, Some database applicatins have a tooltip feature where when you are dragging the scrollbar of the table view a tooltip appears next to the mouse cursor displaying the approximate record...
3
by: Daniel Manes | last post by:
I need a strategy to debug this situation... I can't put all the code involved, but here are some of the critical lines with comments: ------------------------- Private _parentDataCell As...
3
by: finleeds | last post by:
hi all I m using the visual studio designer to create 1 Dataset with 1 table with 3 columns : Id, Name, Birthday. Once this done, still with the designer, I m creating a datagridview and...
2
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have an event handler on the CellFormatting event of a DataGridView. This event handler highlights cells that are below a certain threshold. This threshold value may change based on user actions....
1
by: Trey | last post by:
I have an unbound datagridview with three comboboxes (e.g. A, B, C) All three comboboxes share the same datasource and use the same valuemember. If I change the value of say combobox A, then B and...
2
by: Rosco | last post by:
Hello, Quick Overview: I am creating a Windows application using C# and have run across a problem. I’m trying to use a DataGridView in “Bound” mode, but filter the view. I have a database...
1
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
2
by: TG | last post by:
Hi! I am trying to export only the visible columns from a datagridview in my windows form in VB 2008. Should't it be no comma after the first row where the headers are? Also should...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.