vbMarkO
Well-known member
- Joined
- Aug 19, 2005
- Messages
- 157
OK Here is my code.
You will note that the AutoIncrementSeed = 1 is Green at the moment because I commented it out so I could get past an error that kept happening.
At first the app is working fine but after closing then coming back and adding another row of data if the Mem_T Column was showing lets say 3 records...
Well if I add another record Mem_T should increment to 4 but it increments to 5 or more.....
Disabling AutoIncrementSeed = 1 stopped this... but the tutorial I was following called for it.... can anyone tell me whats wrong... and if it works without it why do I need it?
OK another question about the above code is this.... How can I size the DataGridView cells to the size I want ....
I would like to size for instance the Mem_T Cells to be no more than 3 digits
How would I do this?
The State Comumn only as wide the Column header itself things like that
I would like however the address city, and phone to be as wide as the data in the cells
IS this possible to make it do all of this or am I hoping for to much here?
One more quesstion.... As you can see this is being saved to an xml FIle my question is this...
How might I call only The Last_Names from the xml File that start with B or T and populate the datagrid with just them.... and then if needed return to all records....???
I hope I am not asking to much at once... but these areas I am very interested in.....
Thanx in advance
vbMarkO
You will note that the AutoIncrementSeed = 1 is Green at the moment because I commented it out so I could get past an error that kept happening.
At first the app is working fine but after closing then coming back and adding another row of data if the Mem_T Column was showing lets say 3 records...
Well if I add another record Mem_T should increment to 4 but it increments to 5 or more.....
Disabling AutoIncrementSeed = 1 stopped this... but the tutorial I was following called for it.... can anyone tell me whats wrong... and if it works without it why do I need it?
Code:
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Dim dtMembers As DataTable Create DataTable
Dim dsChurchMem As DataSet Next Create Dataset
Dim xmlFile As String = "..\Membership.xml" Now name xml File
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dtMembers = New DataTable("Members")
dtMembers.Columns.Add("Mem_T", GetType(Int32))
dtMembers.Columns.Add("Last_Name", GetType(String))
dtMembers.Columns.Add("First_Name", GetType(String))
dtMembers.Columns.Add("Phone", GetType(String))
dtMembers.Columns.Add("Address", GetType(String))
dtMembers.Columns.Add("City", GetType(String))
dtMembers.Columns.Add("State", GetType(String))
dtMembers.Columns.Add("Zip", GetType(String))
With dtMembers.Columns("Mem_T")
.AutoIncrement = True
.AutoIncrementSeed = 1 This seems to mess it up by making the Mem_T high by 1 or more???
End With
dsChurchMem = New DataSet("ChurchMembership") DataSet
dsChurchMem.Tables.Add(dtMembers)
dgMembers.DataSource = dsChurchMem
dgMembers.DataMember = "Members"
End Sub
Private Sub btnSaveData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveData.Click
dsChurchMem.WriteXml(xmlFile)
End Sub
Private Sub btnMemRecords_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMemRecords.Click
If File.Exists(xmlFile) Then
dsChurchMem.ReadXml(xmlFile)
End If
End Sub
End Class
OK another question about the above code is this.... How can I size the DataGridView cells to the size I want ....
I would like to size for instance the Mem_T Cells to be no more than 3 digits
How would I do this?
The State Comumn only as wide the Column header itself things like that
I would like however the address city, and phone to be as wide as the data in the cells
IS this possible to make it do all of this or am I hoping for to much here?
One more quesstion.... As you can see this is being saved to an xml FIle my question is this...
How might I call only The Last_Names from the xml File that start with B or T and populate the datagrid with just them.... and then if needed return to all records....???
I hope I am not asking to much at once... but these areas I am very interested in.....
Thanx in advance
vbMarkO