Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

TheBlindWatchmaker

@TheBlindWatchmaker
About
Posts
45
Topics
22
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • XML File -> DataGridView - One additional row of data
    T TheBlindWatchmaker

    Hi all, I am trying to implement read and write functionality between DataGridViewload controls and an XML file. The code to write the the XML file is as follows

    DataTable dt_csk = new DataTable("CONTROL_KEYS");
    dt_csk.Columns.Add("key", typeof(System.String));
    dt_csk.Columns.Add("value", typeof(System.String));

    for (idx = 0; idx < dgv_csk.Rows.Count; idx++)
    {
    dt_csk.Rows.Add(dgv_csk[0, idx].Value.ToString(), dgv_csk[1, idx].Value.ToString());
    }

    dt_csk.EndLoadData();
    dt_csk.AcceptChanges();
    dgv_csk.DataSource = dt_csk.DefaultView;

    I then add all DataTables to a DataSet like so

    DataSet ds = new DataSet();
    ds.Tables.Add(dt_csk);
    ds.Tables.Add(dt_cdk);
    ds.Tables.Add(dt_cak);

    /* Output the contents of the DataSet as an XML file */
    ds.WriteXml(logfile, XmlWriteMode.IgnoreSchema);

    I read the XML into the DataGridView elements as follows:

    XmlDataDocument xmldata = new XmlDataDocument();
    xmldata.DataSet.ReadXml(xml_filename);

    dgv_csk.DataSource = xmldata.DataSet;

    dgv_csk.DataMember = "CONTROL_STATIC_KEYS";

    This works great but there is one problem. PROBLEM When I import info from the XML file, there is one additional row that is blank in each DataGridView control. I have some other functions where I use the number of rows in the DGV as an index, and this additional row is screwing things up. Could you tell me what I am doing wrong? Thanks! N.

    modified on Monday, August 29, 2011 1:57 AM

    C# database xml help question

  • Is an Array of Dictionaries the solution here?
    T TheBlindWatchmaker

    I will not be displaying more than one use case at once. However, the user will have the option to save the results of the registry key to a file (I think I am going to go with XML for that). Given this, it appears that I might have to declare dictionaries for all these use cases...

    C# question help windows-admin data-structures tools

  • Is an Array of Dictionaries the solution here?
    T TheBlindWatchmaker

    Hi Bob, I have a follow-up question. Is there a way for me to avoid declaring 10 * 7 = 70 dictionaries? 10 is the number of use-cases and 7 is the number of dictionaries I would require for each use case. I have a group of radio controls (gb_profiles) on the GUI and have been able to edit its CheckedChanged function to derive the index of the control that has been checked.

    private void rb_prof_CheckedChanged(object sender, EventArgs e)
    {
    /* We are doing the following here:
    * 1. Identifying the radio button selected
    * 2. Setting the profile_selected variable using the radio button index
    */

            foreach (Control ctl in gb\_profiles.Controls) 
            {
                if (sender.Equals(ctl))
                {
                    profile\_selected = gb\_profiles.Controls.IndexOf(ctl);
                }
            }
         }
    

    How do I use this to load the dictionary with only the values for this profile? Thanks for your help!

    C# question help windows-admin data-structures tools

  • Is an Array of Dictionaries the solution here?
    T TheBlindWatchmaker

    BobJanova wrote:

    The keys you are looking up (for each dictionary) are just within one registry node, right? Otherwise the above advice is correct, you should use a control with tree capabilities.

    Yes, they are.

    BobJanova wrote:

    A list of dictionaries is probably appropriate.
     
    You can only have one set of controls, and switch their data sources when the profile changes.

    Thank you! I will look into the list of dictionaries.

    C# question help windows-admin data-structures tools

  • Is an Array of Dictionaries the solution here?
    T TheBlindWatchmaker

    PIEBALDconsult wrote:

    The registry is evil, don't use it.

    Unfortunately, I have to :)

    class="FQA">PIEBALDconsult wrote:

    1. DataGridView is evil and likely an inappropriate control for your purpose.

    Not sure why the DGV is so evil but it does work quite nicely for the purpose of my project.

    PIEBALDconsult wrote:

    1. The registry is a tree, why not use a TreeView?

    I will look into using a TreeView... I did not know about this when I started working on my utility and I have the information displayed the way it is required. However, it might not be too late to rethink this design... thanks for the tip! :)

    C# question help windows-admin data-structures tools

  • Is an Array of Dictionaries the solution here?
    T TheBlindWatchmaker

    Hi all, First some context to my question: I am working on a utility that queries the Windows registry for a large number of keys set by a particular application. I am using multiple DataGridView (DGV) controls to display the information (Reg Key and Value) on my form. Each DGV is tied to a Dictionary using a BindingSource. This has worked out fine for all sets of keys except for one. - This application has provision for 10 different user-profiles. - Associated with each user-profile are 7 SETS of feature keys. - At any given time, the user needs to see the settings for only ONE of the 10 profiles. - On my form, I have a collection of radiobuttons that I use to select a profile. PROBLEM: 1. Should I use an array of dictionaries (dimension 1: profile; dimension 2: feature)? If so, how do I do this? If not, what is a better solution? 2. Can I have only 1 set of DGVs (representing the feature keys), so when I click between profiles, the DGVs are updated with the values for that profile? Thanks for your help!

    C# question help windows-admin data-structures tools

  • TextBoxes, ListView, DataGrid or something else?
    T TheBlindWatchmaker

    Thanks Mycroft, Wayne and Bob for your very helpful replies. So, I have this now: // In Form1.Designer.cs private System.Windows.Forms.DataGridView dgv_static_keys; // In Form1.cs Dictionary<string, string> dict_static_keys = new Dictionary<string, string> { {"Key1", "Value1"}, {"Key2", "Value2"}, {"Key3", "Value3"}, }; BindingSource bindingsource = new BindingSource(); bindingsource .DataSource = dict_static_keys; dgv_static_keys.DataSource = bindingsource; If I were to now update the Dictionary with a new key, say dict_static_keys.Add("Key4", "Value4"); How do I get the DataGridView to update? I tried this dg_static_keys.DataSource = dict_static_keys.ToList(); but is there a better solution?

    C# question csharp database visual-studio windows-admin

  • TextBoxes, ListView, DataGrid or something else?
    T TheBlindWatchmaker

    Thanks, Mycroft. I could create a list of registry key names and bind that list as the datasource to the datagridview. However, when the application runs, it will have to query the registry for each of those key names and then display the values of the key in the second column. To clarify, when the application is first opened, I will have: NAME VALUE Key1 (blank) Key2 (blank) Key3 (blank) ... When I click on "Run", I want to see NAME VALUE Key1 Value1 Key2 Value2 Key3 Value3 ... Should I then put Key1, Key2, Key3, etc... in a List? Thanks!

    C# question csharp database visual-studio windows-admin

  • TextBoxes, ListView, DataGrid or something else?
    T TheBlindWatchmaker

    Hi all, I am working on a an application that needs to do the following: 1. Query the registry for all the keys (approx. 100) that are written by another application and 2. Displays this information on a form. 3. Write this information to a log file. I am using Visual Studio .NET 2010 on a Win 7 machine. The limitation I have to work with is that I have to use the .NET 3.5 framework since that is what is installed with Win 7. I have steps 1 and 3 figured out but I have a question about step 2. What control(s) should I use to display this information? The display itself can be very simple, for example: REGISTRY KEY VALUE KEY 1 0 KEY 2 20 KEY 3 0x3FF ... NOTE: The Key names will be populated in advance by the application. The Values will be populated upon each query. Should I use several TextBoxes? This appears to be the brute force method and not very scalable. I tried playing with a ListView but it doesn't seem like I can update only the "Value" column. What would you suggest?

    C# question csharp database visual-studio windows-admin

  • Reading in 16 and 24-bit audio data into (32-bit) integer buffers
    T TheBlindWatchmaker

    Thank you very much for your clear explanation and the code! It has been of great help and I modified it to exactly what I wanted. Muchas Gracias! N.

    C / C++ / MFC c++ docker question

  • Reading in 16 and 24-bit audio data into (32-bit) integer buffers
    T TheBlindWatchmaker

    Hello! Here is what I am trying to do. I am writing an audio processing program that can read 16 and 24 bit WAV files into int (32-bit) buffers. The 16-bit condition is straight-forward: I would read in the required number of bits into short buffers. However, since C++ does not have a native 24-bit datatype, and I would like to use the same buffer for 16 or 24 bit data, I would have to read the WAV file data into int buffers. The further processing that the program does is on the ENTIRE contents of the int buffer and NOT on a byte-by-byte basis. I have written the WAV read/write part of the program. Where I am running into a bit of difficulty is unpacking three bytes of data (24-bits) into a 32-bit container. Should I copy the contents of the audio file into a temporary buffer as contiguous data and then fill my main buffer with three bytes of this data, and then skip a byte? Is there any other way that you would recommend reading 24-bit data into a 32-bit buffer? Thank you for your pointers, as it were. I do not expect code to be written for me, but pseudocode would be immensely helpful. Thanks!

    C / C++ / MFC c++ docker question

  • Help importing XML data into forms
    T TheBlindWatchmaker

    Greetings! For an application I'm writing, I require to be able to save data to an XML file and, when necessary, be able to import that data into my forms. I have no problem in writing the data to an XML file. I also have rudimentary familiarity with XMLTextReader in that I can read the name of a node and its value. However, my question is this: What would be the best way to go through an existing XML file with a schema similar to that below and fill in values for Object0 to Object "n" in a form? A B C D E F ... etc < I was wondering if there was a better method than checking for each node name and then filling the appropriate box in the form with the node's value. What would be a recommended method for doing this? Thanks!

    C# xml help question database

  • Basic XML Parser
    T TheBlindWatchmaker

    Thank you! Do you know of a similar set of tutorials for C#?

    C# xml help question

  • Basic XML Parser
    T TheBlindWatchmaker

    Hi, I'd like to write a basic parser in XML to write the values of various fields across several forms to a text file. The idea is that custom settings of all these fields can be stored as a "user config" that can be recalled. Could you help point me towards information online that will help me get started? I would like to start with a test app that writes several values to a text file and then reads then back into the form. Thanks!

    C# xml help question

  • Help with Collections
    T TheBlindWatchmaker

    ...

    C# help question

  • Help with Collections
    T TheBlindWatchmaker

    Greetings! I have a set of 6 RadioButtons, one of which is set based on a user-selection in a ListBox on the same form. What I want to do is to disable the other 5 RadioButtons after the user makes the selection and one RadioButton is set. I'm assuming that a collection is the best way to do this, so I can write some code that disables every RadioButton that is not the one that is selected. Could you help me define this Collection? I've looked through MSDN and pages online but I'm a little confused about how one defines a collection. Thanks!

    C# help question

  • Problem connecting to an MS Access Database [modified]
    T TheBlindWatchmaker

    Wow... thanks, mate! You're a huge help... I really appreciate this! I just figured out that making the following change in my AppDatabaseInterface.cs file did the trick for me: if (!found) alMakes.Add(make); but your approach on the whole seems better and I'm going to look into it. Thank you very much! N.

    C# help database

  • Problem connecting to an Access database
    T TheBlindWatchmaker

    Hi Guffa, The Makes field has, say, 10 speakers from Mfr1, 10 from Mfr2 etc. I want the combo box to show Mfr1, Mfr2 and so on. How would you suggest I do this? Thanks for your time!

    C# help database design

  • Problem connecting to an MS Access Database [modified]
    T TheBlindWatchmaker

    Thanks for your reply! There is no run-time error. The code compiles and runs just fine. The form comes up but the combo box has nothing in it. I've stepped through the code to make sure that the database connection sees the Access file.

    C# help database

  • Problem connecting to an Access database
    T TheBlindWatchmaker

    Damnit! I'm really inept today! Apologies, apologies! This might be it! :) public string[] Makes { get { OleDbDataReader dbr = null; ArrayList Makes = new ArrayList(); OleDbCommand cmd = new OleDbCommand(string.Format("SELECT * FROM {0};", "Speakers"), m_dbConn); dbr = cmd.ExecuteReader(); // Read each record one at a time ... while (dbr.Read()) { // Load our arrays with the Field names // and values. NOTE: Reloading the field // names over and over again is probably // redundant, but I'm not sure that the order // column names are returned is fixed. for (int it = 0; it < dbr.FieldCount; it++) { string strField = dbr.GetName(it); if (strField == "MAKE") { string make = (string)dbr.GetValue(it); bool found = false; foreach (object o in Makes) { if ((string)o == make) { found = true; break; } } if (found) Makes.Add(make); break; } } } string[] strMakes = new string[Makes.Count]; int i= 0; foreach (object o in Makes) { strMakes[i++] = (string)o; } return strMakes; } }

    C# help database design
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups