473,386 Members | 1,745 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,386 software developers and data experts.

limit number of rows in vb.net datagrid

Hi

I've a problem. Can anyone help. I would like to use datagrid for data
entry. How can I set the number of rows in the datagrid. And use the
datagrid to update the ms sql table.

regards
melson
Nov 21 '05 #1
4 10449
"Melson" <we****@hotmail.com> wrote in message
news:OX**************@TK2MSFTNGP09.phx.gbl...
Hi

I've a problem. Can anyone help. I would like to use datagrid for data
entry. How can I set the number of rows in the datagrid. And use the
datagrid to update the ms sql table.

regards
melson


You could use the usual dataadaptor and dataset route.
Make your select sql choose no data.
Loop appending blank records to the dataset.
If you use stored procedures to update then you can probably do something in
there avoids actually inserting blank records to your table.
--
Regards,
Andy O'Neill
Nov 21 '05 #2
Hi Andy

Thanks for your help. I've done what you told me and it works. However, i'm
still frustrated because i'm still stuck with this project. Pls help. Is
there any example. I really appreciate if anyone can help me. I've tried to
solve this for weeks but still fail.
Description
I would like to create a data entry form using vb.net. It is a master-detail
windows form which the upper section is the product code(master) and the
lower section is the part information (detail). The lower section is make up
of a datagrid. First column is the part code and second column is part
description. When user pressed the Enter key in the part code column, it
opens the Part code form for the user to choose the part code. User can add
as many part code as possible with the same product code.

User is able to perform Add, Edit and Delete function on data entry form. It
is connected to ms sql database.
What I've tried

I've tried to create a windows control library with the following code
below. Then add the dll into the Toolbox. It is able to capture the Enter
key. However, there are problems which I faced.

a.. It captures Enter key in every column. e.g Part code column, Part
description column

b.. How can I open Part code form so that user can choose part code into
the datagrid

a.. How can I perform Add, Edit and Delete record which connect to ms sql.

code

Protected Overrides Function ProcessCmdKey(ByRef msg As
System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As
Boolean

If msg.WParam.ToInt32() = CInt(Keys.Enter) Then

MsgBox("entered")

SendKeys.Send("{Tab}")

Return True

End If


Return MyBase.ProcessCmdKey(msg, keyData)

End Function 'ProcessCmdKey


"Andy O'Neill" <ao***************@lycos.co.uk> wrote in message
news:iX******************@fe2.news.blueyonder.co.u k...
"Melson" <we****@hotmail.com> wrote in message
news:OX**************@TK2MSFTNGP09.phx.gbl...
Hi

I've a problem. Can anyone help. I would like to use datagrid for data
entry. How can I set the number of rows in the datagrid. And use the
datagrid to update the ms sql table.

regards
melson


You could use the usual dataadaptor and dataset route.
Make your select sql choose no data.
Loop appending blank records to the dataset.
If you use stored procedures to update then you can probably do something
in there avoids actually inserting blank records to your table.
--
Regards,
Andy O'Neill

Nov 21 '05 #3

"Melson" <we****@hotmail.com> wrote in message
news:uC**************@TK2MSFTNGP12.phx.gbl...
Hi Andy

Thanks for your help. I've done what you told me and it works. However,
i'm still frustrated because i'm still stuck with this project. Pls help.
Is there any example. I really appreciate if anyone can help me. I've
tried to solve this for weeks but still fail.
Description
I would like to create a data entry form using vb.net. It is a
master-detail windows form which the upper section is the product
code(master) and the lower section is the part information (detail). The
lower section is make up of a datagrid. First column is the part code and
second column is part description. When user pressed the Enter key in the
part code column, it opens the Part code form for the user to choose the
part code. User can add as many part code as possible with the same
product code.

User is able to perform Add, Edit and Delete function on data entry form.
It is connected to ms sql database.
What I've tried

I've tried to create a windows control library with the following code
below. Then add the dll into the Toolbox. It is able to capture the Enter
key. However, there are problems which I faced.

a.. It captures Enter key in every column. e.g Part code column, Part
description column
You can add handlers for all sorts.
I would think you could maybe inherit your own control from the textbox
goes in a grid and handle the return key in it.
But.
I would also suggest that this is maybe rather doing things the hard way.
Adding a column with just a button in it is maybe easier.
I think there's an example on george shepherd's faq site about adding a
button.

b.. How can I open Part code form so that user can choose part code into
the datagrid
A drop down combo is no good to you?
Lot of parts perhaps.

Hand over the calling form as an object.
Add a public procedure (method) allows the called form to set the part code.

a.. How can I perform Add, Edit and Delete record which connect to ms
sql.


Read up about dataadaptors and datasets.

Nov 21 '05 #4
Hi Andy

Thanks very much for your help. I've tried to add 2 component class to my
project, DataGridComboColumn.vb and NoKeyUpCombo.vb. Below are the following
code. Actually I try to amend a sample code which has combobox in datagrid
to textbox in datagrid. But having problem at AddHandler
ColumnTextBox.KeyPress, New EventHandler(AddressOf CheckEnterKey) in green
color.

Can you guide me how to solve this problem so that when Enter key is pressed
in the textbox, it will display form3. Another request is how to pass
parameter between the forms. e.g user choose part code from form3 and
display in the main form datagrid.

Thanks.

DataGridComboBoxColumn.vb code
Namespace DataGridTextBoxCombo
Public Class DataGridComboBoxColumn
Inherits DataGridTextBoxColumn

' use the derived nokeyup combo to avoid tabbing problem
Public WithEvents ColumnTextBox As NoKeyUpCombo
Private WithEvents _source As CurrencyManager
Private _rowNum As Integer
Private _isEditing As Boolean
Public Sub New()
MyBase.New()
_source = Nothing
_isEditing = False
ColumnTextBox = New NoKeyUpCombo

AddHandler ColumnTextBox.Leave, New EventHandler(AddressOf
LeaveComboBox)
AddHandler ColumnTextBox.KeyPress, New EventHandler(AddressOf
CheckEnterKey)

End Sub

Private Sub LeaveComboBox(ByVal sender As Object, ByVal e As EventArgs)
If _isEditing Then
SetColumnValueAtRow(_source, _rowNum, TextBox.Text)
_isEditing = False
Invalidate()
End If
ColumnTextBox.Hide()
End Sub

Private Sub checkkey(ByVal sender As Object, ByVal e As EventArgs)
Dim frmt As New Form3
If e.KeyChar = Chr(13) Then
frmt.Show()
End If
End Sub
NoKeyUpCombo.vb code
Namespace DataGridTextBoxCombo
Public Class NoKeyUpCombo
Inherits TextBox
Private WM_KEYUP As Integer = &H101
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_KEYUP Then
'ignore keyup to avoid problem with tabbing & dropdownlist;
Return
End If
MyBase.WndProc(m)
End Sub 'WndProc
End Class 'NoKeyUpCombo
End Namespace



"Andy O'Neill" <ao***************@lycos.co.uk> wrote in message
news:5u******************@fe3.news.blueyonder.co.u k...

"Melson" <we****@hotmail.com> wrote in message
news:uC**************@TK2MSFTNGP12.phx.gbl...
Hi Andy

Thanks for your help. I've done what you told me and it works. However,
i'm still frustrated because i'm still stuck with this project. Pls help.
Is there any example. I really appreciate if anyone can help me. I've
tried to solve this for weeks but still fail.
Description
I would like to create a data entry form using vb.net. It is a
master-detail windows form which the upper section is the product
code(master) and the lower section is the part information (detail). The
lower section is make up of a datagrid. First column is the part code and
second column is part description. When user pressed the Enter key in the
part code column, it opens the Part code form for the user to choose the
part code. User can add as many part code as possible with the same
product code.

User is able to perform Add, Edit and Delete function on data entry form.
It is connected to ms sql database.
What I've tried

I've tried to create a windows control library with the following code
below. Then add the dll into the Toolbox. It is able to capture the Enter
key. However, there are problems which I faced.

a.. It captures Enter key in every column. e.g Part code column, Part
description column


You can add handlers for all sorts.
I would think you could maybe inherit your own control from the textbox
goes in a grid and handle the return key in it.
But.
I would also suggest that this is maybe rather doing things the hard way.
Adding a column with just a button in it is maybe easier.
I think there's an example on george shepherd's faq site about adding a
button.

b.. How can I open Part code form so that user can choose part code into
the datagrid


A drop down combo is no good to you?
Lot of parts perhaps.

Hand over the calling form as an object.
Add a public procedure (method) allows the called form to set the part
code.

a.. How can I perform Add, Edit and Delete record which connect to ms
sql.


Read up about dataadaptors and datasets.

Nov 21 '05 #5

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

Similar topics

1
by: Peter | last post by:
I have a web page with an datagrid which users can update. The update event fires if the datagrid has a relatively few number of rows (eg 100). However if a user selects a dataset with a large...
0
by: D. Dante Lorenso | last post by:
I need to know that original number of rows that WOULD have been returned by a SELECT statement if the LIMIT / OFFSET where not present in the statement. Is there a way to get this data from PG ?...
3
by: Colleyville Alan | last post by:
From the MS Access help I have seen the limits on number of fields in an index, objects in a db, etc. But I have seen no mention on a limit of rows. I am considering an application that would have...
3
by: Rakesh | last post by:
Hi, Is there any limit to the number of rows a datagrid can display? Thanks, Rakesh
10
by: VM | last post by:
How can I limit the use of the PC's virtual memory? I'm running a process that basically takes a txt file and loads it to a datatable. The problem is that the file is over 400,000 lines long (77...
10
by: Aaron Smith | last post by:
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...
2
by: patang | last post by:
I found the following to count the total number of VISIBLE rows of datagrid datagrid.visiblerowcount How do we count the total number of ACTUAL (not just visible) rows of datagrid? Thanks...
2
by: Ivan V via DotNetMonster.com | last post by:
Dear All: I would like to know if there are limit rows that can add in the datgrid or not? I got a problem in adding rows in the datagrid. it only allows me to add 5 rows only. Any ideas on...
2
by: Jeff | last post by:
I have a Asp.Net 1.1 application of which I have a very large datagrid on one of my pages. I am populating the datagrid by loading a xml file that is being stored in viewstate. After I have the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...

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.