- VBForums
- Visual Basic
- Visual Basic 6 and Earlier
- How can add row in DataGrid ?
- If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
Results 1 to 12 of 12 Thread: How can add row in DataGrid ? - Dec 16th, 2008, 07:01 AM #1 memoon
- View Profile
- View Forum Posts
Thread Starter Member Join Date Jul 2007 Posts 34 How can add row in DataGrid ? Hi How can add row in DataGrid ? Thanks Reply With Quote - Dec 16th, 2008, 07:18 AM #2 Hack
- View Profile
- View Forum Posts
I'm about to be a PowerPoster! Join Date Aug 2001 Location Searching for mendhak Posts 58,333 Re: How can add row in DataGrid ? Add a new record to your datasource. Reply With Quote - Dec 16th, 2008, 07:26 AM #3 memoon
- View Profile
- View Forum Posts
Thread Starter Member Join Date Jul 2007 Posts 34 Re: How can add row in DataGrid ? no i have 3 text in forn text1 , text2, text3 How can add row in DataGrid ? the data row from text do not save in databases only in form Reply With Quote - Dec 16th, 2008, 09:50 AM #4 Caskbill
- View Profile
- View Forum Posts
Hyperactive Member Join Date Oct 2007 Location Indiana Posts 295 Re: How can add row in DataGrid ? Why are you using a Datagrid? If your data is coming from text boxes, why not just use the MSFlexGrid control? To increase by one row in a Flesgrid the code would be... Code: MSFlexgrid1.rows = MSFlexgrid1.rows + 1 Reply With Quote - Dec 16th, 2008, 12:08 PM #5 memoon
- View Profile
- View Forum Posts
Thread Starter Member Join Date Jul 2007 Posts 34 Re: How can add row in DataGrid ? hi i use datagrid not MSFlexgrid can i add row in DataGrid from text ? datagrid only not MSFlexgrid please help me Reply With Quote - Dec 17th, 2008, 06:34 AM #6 memoon
- View Profile
- View Forum Posts
Thread Starter Member Join Date Jul 2007 Posts 34 Re: How can add row in DataGrid ? can that or no ? please answer me Reply With Quote - Dec 17th, 2008, 07:21 AM #7 dee-u
- View Profile
- View Forum Posts
- Visit Homepage
Software Carpenter Join Date Feb 2005 Location Pinas Posts 11,123 Re: How can add row in DataGrid ? The DataGrid is bound to a recordset, as such in order for it to Add new rows you will need to add records to your database which will be reflected in the DataGrid. Regards, ™ As a gesture of gratitude please consider rating helpful posts. c",) Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system Reply With Quote - Dec 17th, 2008, 01:11 PM #8 brucevde
- View Profile
- View Forum Posts
PowerPoster Join Date Oct 2002 Location British Columbia Posts 9,758 Re: How can add row in DataGrid ? The DataGrid requires an OLEDB Datasource such as an ADO Recordset. As Hack & dee-u pointed out, to add a new row to the DataGrid simply add a record to it's underlying Recordset. You haven't indicated your requirements other than you don't want to use a database. Good news you don't need one. You can create and use an in-memory ADO Recordset. Add a Reference to the Microsoft ActiveX Data Object 2.X Library to your project. Code: Private Sub Form_Load() Dim rs As ADODB.Recordset 'Don't allow user to modify data in grid directly. With DataGrid1 .AllowAddNew = False .AllowDelete = False .AllowUpdate = False End With 'create an in-memory recordset with your required fields Set rs = New ADODB.Recordset rs.Fields.Append "LastName", adVarChar, 30 rs.Fields.Append "FirstName", adVarChar, 15 rs.Open 'bind recordset to Grid Set DataGrid1.DataSource = rs End Sub Private Sub cmdAdd_Click() Dim rs As ADODB.Recordset 'get the Grid's Recordset and add a new Record Set rs = DataGrid1.DataSource rs.AddNew Array("LastName", "FirstName"), Array(txtLastName.Text, txtFirstName.Text) 'you could use this syntax instead 'rs.AddNew 'rs.Fields("LastName").Value = txtLastName.text 'rs.Fields("FirstName").Value = txtFirstName.text 'ReBind the Grid so the new record is visible DataGrid1.ReBind End Sub Note that when the program is closed the data is lost. But it is simple enough to create a Save procedure to write the data to a text file or whatever your needs might be. Reply With Quote - Dec 19th, 2008, 10:28 PM #9 memoon
- View Profile
- View Forum Posts
Thread Starter Member Join Date Jul 2007 Posts 34 Re: How can add row in DataGrid ? thanks for soultion my Error Reply With Quote - Aug 5th, 2020, 08:08 AM #10 SaudVb
- View Profile
- View Forum Posts
Junior Member Join Date Apr 2020 Posts 29 Re: How can add row in DataGrid ? Originally Posted by brucevde The DataGrid requires an OLEDB Datasource such as an ADO Recordset. As Hack & dee-u pointed out, to add a new row to the DataGrid simply add a record to it's underlying Recordset. You haven't indicated your requirements other than you don't want to use a database. Good news you don't need one. You can create and use an in-memory ADO Recordset. Add a Reference to the Microsoft ActiveX Data Object 2.X Library to your project. Code: Private Sub Form_Load() Dim rs As ADODB.Recordset 'Don't allow user to modify data in grid directly. With DataGrid1 .AllowAddNew = False .AllowDelete = False .AllowUpdate = False End With 'create an in-memory recordset with your required fields Set rs = New ADODB.Recordset rs.Fields.Append "LastName", adVarChar, 30 rs.Fields.Append "FirstName", adVarChar, 15 rs.Open 'bind recordset to Grid Set DataGrid1.DataSource = rs End Sub Private Sub cmdAdd_Click() Dim rs As ADODB.Recordset 'get the Grid's Recordset and add a new Record Set rs = DataGrid1.DataSource rs.AddNew Array("LastName", "FirstName"), Array(txtLastName.Text, txtFirstName.Text) 'you could use this syntax instead 'rs.AddNew 'rs.Fields("LastName").Value = txtLastName.text 'rs.Fields("FirstName").Value = txtFirstName.text 'ReBind the Grid so the new record is visible DataGrid1.ReBind End Sub Note that when the program is closed the data is lost. But it is simple enough to create a Save procedure to write the data to a text file or whatever your needs might be. brucevde .. Yours is an example of a high-quality answer; most solutions on the internet are either half-mindedly put, too complicated, or are meant for off-showing purposes. Thank you very much; you solved my problem. Reply With Quote - Aug 6th, 2020, 05:58 PM #11 SaudVb
- View Profile
- View Forum Posts
Junior Member Join Date Apr 2020 Posts 29 Re: How can add row in DataGrid ? How to make it save data into the actual database instead of having it save into an in-memory recordset? Reply With Quote - Aug 7th, 2020, 06:44 PM #12 SaudVb
- View Profile
- View Forum Posts
Junior Member Join Date Apr 2020 Posts 29 Re: How can add row in DataGrid ? Since it is an in-memory recordset, is there a way to save its data for next program session? Reply With Quote Quick Navigation Visual Basic 6 and Earlier Top - Site Areas
- Settings
- Private Messages
- Subscriptions
- Who's Online
- Search Forums
- Forums Home
- Forums
- Visual Basic
- Visual Basic .NET
- CodeBank - VB.net
- Visual Basic 6 and Earlier
- CodeBank - Visual Basic 6 and earlier
- TwinBASIC
- CodeBank - TwinBASIC
- Universal Windows Platform and Modern Windows Experience
- Xamarin
- Mobile Development
- ASP, VB Script
- Office Development
- Database Development
- Reporting
- API
- Games and Graphics Programming
- Game Demos
- COM and ActiveX
- Network Programming
- Visual Basic FAQs
- Slow Chat with the Microsoft Visual Basic team
- .NET and More
- ASP.NET And ASP.NET Core
- Visual Basic .NET
- MVC .Net
- C#
- Microsoft Azure and Cloud Dev
- WPF, WCF, WF
- .NET Architecture and Design
- Silverlight
- General
- General Developer Forum
- IoT, IoE, and Maker Forum
- Testers and Testing
- Application Testing
- Application Deployment
- Linux Development
- General PC
- VBForums Coding Contests
- Contest Entries
- Code It Better
- Maths Forum
- Other Languages
- Other BASIC
- C and C++
- Java
- PHP
- XML, HTML, Javascript, Web and CSS
- jQuery
- Assembly
- Other Programming Languages
- VBForums CodeBank
- CodeBank - Visual Basic .NET
- CodeBank - Visual Basic 6 and earlier
- CodeBank - ASP / ASP.NET / Blazor / MVC / Web API
- CodeBank - C#
- CodeBank - C++
- CodeBank - Java / J#
- CodeBank - PHP
- Codebank - Game Programming
- Codebank - Mobile Development
- CodeBank - JavaScript
- Codebank - Cascading Style Sheets (CSS)
- CodeBank - Other
- VBForums UtilityBank
- UtilityBank - Utilities
- UtilityBank - IDE Add-Ins
- UtilityBank - Components
- UtilityBank - Tutorials
- UtilityBank - Other
- Projects
- Project Requests
- Project Communication Area
- Jobs
- Just VB Jobs
- Open Positions (Jobs)
- Looking for Work
- Community
- Forum Feedback
- General Discussion / Chit Chat
- World Events
- Forum Test Area
« Previous Thread | Next Thread » - VBForums
- Visual Basic
- Visual Basic 6 and Earlier
- How can add row in DataGrid ?
Posting Permissions - You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
- BB code is On
- Smilies are On
- [IMG] code is On
- [VIDEO] code is On
- HTML code is Off
Forum Rules | Click Here to Expand Forum to Full Width |