Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

 

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

Visual Basic 2008 Express Edition!
Posted

I am still looking to find out how to get the info from the xml file to populate the Datagrid with only the names that start with "B" for example...

 

Another way this might be done is not to do it from the xml but to simply filter the data that is already in the datagrid so that it simply diaplys the data that contains the last names of the search query.

 

Not sure how to do this just yet though...

 

I have figured out though how to get data from the xml file to populate textbox's....

 

   Sub DisplayMember(ByVal Posistion As Integer)
       Dim node As XmlNode = xmlDoc.SelectSingleNode( _
        "/ChurchMembership/Members[" & Posistion & "]")
       Dim strFname As String = node.SelectSingleNode("First_Name").InnerText
       Dim strLname As String = node.SelectSingleNode("Last_Name").InnerText
       Dim strPhone As String = node.SelectSingleNode("Phone").InnerText

       lblName.Text = strFname & " " & strLname
       lblPhone.Text = strPhone
       


   End Sub

   Private Sub cboMembers_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboMembers.SelectedIndexChanged
       DisplayMember(cboMembers.SelectedIndex + 1)


   End Sub

 

 

The above code allows me to display FIrst name last name and Phone in labels.

 

Using a combobox... I would like to display this data using the datagrid instead though...

 

I am not sure how to find the selected row or the index of the selected row so that I could use it to indicate what data needs to be displayed.

 

Anyideas guys?

 

 

vbMarkO

Visual Basic 2008 Express Edition!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...