0

Hi all I am trying to make a little program that when you type in a number (anydigit) it will search the xml file and display the results in a text box, i have found some code that i would like to modify, the code here has no option to type into but a drop down box. How do I make it so I have to type the number in then click search ?


Help with Code Tags
(Toggle Plain Text)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Linq;
using System.Xml;

namespace example
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            populateCombo();
        }

        private void populateCombo()
        {
            cmbPlatform.Items.Clear();

            XmlDocument doc = new XmlDocument();
		    doc.Load("VideoGames.xml");
		    XmlNodeList nodeList = doc.SelectNodes("VGames/Game");

		    foreach(XmlNode node in nodeList)
                if (!cmbPlatform.Items.Contains(node.SelectSingleNode("Platform").InnerText))
			        cmbPlatform.Items.Add(node.SelectSingleNode("Platform").InnerText);
        }
        
      

        private void butFilter_Click(object sender, EventArgs e)
        {
            XDocument xmlDoc = XDocument.Load("VideoGames.xml");

            var games = from game in xmlDoc.Descendants("Game")
                where game.Element("Platform").Value == cmbPlatform.SelectedItem.ToString()
                select new
                {
                  Title = game.Element("Title").Value,
                  Platform = game.Element("Platform").Value,
                };

            txtResults.Text = "";
            foreach (var game in games)
            {
                txtResults.Text = txtResults.Text + "Title: " + game.Title + "\n";
                txtResults.Text = txtResults.Text + "Platform: " + game.Platform + "\n\n";
            }

            if (txtResults.Text == "")
                txtResults.Text = "No Results.";
        }
    }
}
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Daramy
0

Dear all,
I am currently working with the ThinkGeo Mapsuite in Visual studio using the ThnikGeo APIs. The documentation of APIs for display maps using the Shapefilelayer and Overlay layers are not quite detailed for me. Does any one have code examples to share? My specific challenge is displaying a map image in a Map control on a form by the browser.

thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.