Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Datagridview TextBox column values not displaying properly - VB.Net - Windows Application
 

Datagridview TextBox column values not displaying properly - VB.Net - Windows Application

Hi,

I have a datagridview in vb.net windows application form.
It consists of rows of data with each row having 3 text columns as follows:
  • First column consists of category1(categ1) header.
  • Second column consists of category2(categ2) header (with respect to categ1).
  • Third column consists of Information pertaining to categ1 and categ2.
User can enter as much data as possible in the third column.

Problem
  1. When user enters some 20,000 characters or 25,000 characters or more data in first row third column of the grid, then the remaining rows data can't able to see properly.
  2. When user enters some 20,000 characters or 25,000 characters or more data in a middle row third column of the grid, then the previos rows able to see but the huge data row and below rows data can't able to see properly.

How can i fix this issue?
Thanks in advance...
Sbvkk  Monday, July 27, 2009 1:12 PM
You probably need to provide more information. Whenever using words such as "can't" and "doesn't", it is nearly always necessary to be more specific. Please be specific about what the problem is. You might also need to provide other information, such as whether the third column is a multiple-line or single-line textbox.



Sam Hobbs; see my SimpleSamples.Info
Simple Samples  Monday, July 27, 2009 6:33 PM
Hi Simple,
Thanks for your response.
Sorry for not providing enough information.

Here i am providing more information:
  • For the third column, the wrap mode was set as True (i.e., multiple line textbox)
  • For the datagridview, 'Autosizerowsmode ' was set to 'Displayed cells '

After making the following changes, the contents display in the datagridview was improved (while using vertical scroll bars or while using tab keystroke to move from one cell to another cell) compared to previous.
  • All the columns text display style was set as 'TopLeft ' (previous default i.e., 'Middle Left ')
  • For the datagridview, 'Autosizerowsmode ' was set to 'All Cells ' (previous 'Displayed Cells ')

But the cell which consists of some 25,000 or more characters of data can't able to see completely in the DataGridView.
Also vertical scrolling in the datagridview was also not smooth.
How can i improve my datagridview handling?

Hope the infomation i provided is enough.
  • Edited bySbvkk Tuesday, July 28, 2009 10:02 AM
  • Edited bySbvkk Wednesday, July 29, 2009 7:24 AMRemoved additional line breaks inserted at the bottom of the post
  •  
Sbvkk  Tuesday, July 28, 2009 10:00 AM
I am still not sure I understand the problem. Do you mean that the textbox is too small to show the entire text in some lines of the text? If so then the solution is obvious; either make the textbox in the datagridview bigger or use a separate control for the text. There are many examples of how to handle things such as this; for example, if you have Microsoft Access, look to see what it does for memo fields when the text is too big for the control used for it.

I am reluctant to spend time explaining a solution since you might not like it. There are many ways to solve the problem, most of which are easy to understand.
Sam Hobbs; see my SimpleSamples.Info
Simple Samples  Tuesday, July 28, 2009 10:39 PM
Hi Simple,

Thanks for reply.

Now i will explain my problem in more extract form. May be this will give you an idea what's the problem i am facing.

I placed a datagridview in a form. Properties of my datagridview are as follows (Alphabetically):
  • (Name) : CatagoryDGV
  • AllowUserToAddRows : False
  • AllowUserToDeleteRows : False
  • AlternatingRowsDefaultCellStyle : DataGridViewCellStyle { BackColor=Color [A=255, R=224, G=224, B=224], ForeColor=Color [Desktop], SelectionBackColor=Color [LemonChiffon], SelectionForeColor=Color [Black], Font=[Font: Name=Microsoft Sans Serif, Size=9, Units=3, GdiCharSet=0, GdiVerticalFont=False] }
  • AutoSizeRowsMode : AllCells
  • BackgroundColor : ActiveBorder
  • ColumnHeadersDefaultCellStyle : DataGridViewCellStyle { BackColor=Color [Silver], ForeColor=Color [Desktop], SelectionBackColor=Color [LemonChiffon], SelectionForeColor=Color [ControlText], Font=[Font: Name=Microsoft Sans Serif, Size=8.25, Units=3, GdiCharSet=0, GdiVerticalFont=False], WrapMode=True, Alignment=MiddleLeft }
  • ColumnHeadersHeightSizeMode : AutoSize
  • Columns : <Will be discussed below>
  • DataSource : bs_Category
  • GridColor : Gray
  • Location : 0, 90
  • Modifiers : Friend
  • RowHeadersBorderStyle : Sunken
  • RowHeadersDefaultCellStyle : DataGridViewCellStyle { BackColor=Color [Silver], ForeColor=Color [Desktop], SelectionBackColor=Color [LemonChiffon], SelectionForeColor=Color [ControlText], Font=[Font: Name=Microsoft Sans Serif, Size=8.25, Units=3, GdiCharSet=0, GdiVerticalFont=False], WrapMode=True, Alignment=MiddleLeft }
  • RowHeadersWidth : 19
  • RowHeadersWidthSizeMode : DisableResizing
  • RowTemplate : DataGridViewRow { Index=-1 }
  • Size : 992, 400 (I don't have more than this space in the form. Also form size takes the entire screen size)
  • TabIndex : 5

Columns in the above datagridview along with their properties are as follows:
Columns
1. DataGridViewCheckBoxColumn
  • (Name) : Select_CategoryDGV
  • FalseValue : False
  • Frozen : True
  • Resizable : False
  • ToolTipText : Select
  • TrueValue : True
  • Width : 25
2. DataGridViewTextBoxColumn
  • (Name) : ID_CategoryDGV
  • DataPropertyName : ID
  • DefaultCellStyle : DataGridViewCellStyle { Format=N0 }
  • HeaderText : ID
  • ReadOnly : True
  • Visible : False
  • Width : 95
3. DataGridViewTextBoxColumn
  • (Name) : Categ1_CategoryDGV
  • DataPropertyName : Categ1
  • DefaultCellStyle : DataGridViewCellStyle { Alignment=TopLeft }
  • HeaderText : Category1
  • ReadOnly : True
  • ToolTipText : Category1
  • Width : 200
4. DataGridViewTextBoxColumn
  • (Name) : Categ2_CategoryDGV
  • DataPropertyName : Categ2
  • DefaultCellStyle : DataGridViewCellStyle { Alignment=TopLeft }
  • HeaderText : Category2
  • ReadOnly : True
  • ToolTipText : Category2
  • Width : 200
5. DataGridViewTextBoxColumn
  • (Name) : CategDesc_CategoryDGV
  • DataPropertyName : CategDesc
  • DefaultCellStyle : DataGridViewCellStyle { WrapMode=True, Alignment=TopLeft }
  • HeaderText : Description
  • MaxInputLength : 10000000
  • ReadOnly : True
  • ToolTipText : CategoryDescription (For mulitline entry use Shift+Enter)
  • Width : 535

Now with this arrangement add few rows of data (say 20 rows) into the datagridview.
Add huge amount of data (say some 50000 characters) in any row in the last column of the datagridview.
Add huge lines of data (say some 70 lines) in another row in the last column of the datagridview.

Now try to read the above two rows of data completely using the vertical scrollbars or with tab keystroke.
I hope, you will notice find difficulty in reading all the contents in the cells i described above having more lines and having more data.

Thats the problem i am facing. How can i improve my datagridview?

I think, you can reproduce my problem with the information i given in this post.
If still i am missing, please let me know...

Once again thanks for spending time for helping me.
  • Edited bySbvkk Wednesday, July 29, 2009 7:26 AM
  •  
Sbvkk  Wednesday, July 29, 2009 7:22 AM

You can use google to search for other answers

Custom Search

More Threads

• Unable to see TableAdapters from 2nd Project in Web Solution
• Datagrid Header as Combo box
• looking for list control
• ForEach and ByRef in LINQ
• Complicated DataGridView with Combobox problem
• How can you achieve single click editing in a DataGridView
• Getting the Current Rows displayed in a DataGrid
• DataGridView does't show updated data from dataset
• help - can dataview filter out columns as well as rows?
• Datagrid row headers