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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
R

Ronni Marker

@Ronni Marker
About
Posts
45
Topics
20
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • newbie XML question that I should have been able to do on my own.
    R Ronni Marker

    Hi, I have an XML file that looks like this

      <?xml version="1.0" standalone="yes" ?> 
      <DocumentElement>
      <Templates>
      <id>a22c77b3-96f4-483c-9642-269fd49cd9c3</id> 
      <title>This is a title</title> 
      <template>This is content.</template> 
      </Templates>
      </DocumentElement>
    

    What I am trying to do... is simply to below the set of existing nodes.

    - <Templates>
      <id>anotherguidstring</id> 
      <title>This is another title</title> 
      <template>yes, yes more content here.</template> 
      </Templates>
    

    Anyone who have time to give me a heads up on this? aparently hangover saturdays have wiped out everything that I should be able to do with my left hand. - oh yea no linq, am on C#2.0.

    C# csharp question wpf linq xml

  • Programmingly Change treeview indexes
    R Ronni Marker

    Ofcause! Thanks buddy. Is there any way to move a node to a specific index? ie when I do a sort, I can't "lock" some nodes, so have to move them back to the index location again.

    C# question database tutorial

  • Programmingly Change treeview indexes
    R Ronni Marker

    I have a Treeview where I want to programmingly change index, but aparently that is a challenge that is more than I can do on my own. My treeview looks like this Node1(Groups) +Child1 +Child2 +Child3 Node2(New node to insert) Node3(Search Result) Above is the wanted treeview layout. I have manually added Node1 with child nodes, and Node3. Now I wanted to add the node, as in this example called Node2, but how do i add this node, sort the Node rows and still make sure that Node1 stay in top and Node3 always is at the end? Any taker on this idea? I had initially thought to change treeview1.nodes["Node1"].index = 0 and treeview.nodes["Node3"].index = treeview1.lastindex, but that would not work, as index is read only.

    C# question database tutorial

  • Aborting a Thread.
    R Ronni Marker

    Nope, not really. Well I could move to backgroundworker... But there should(right?) be a way to abort the thread without getting into the deep end.

    C# windows-admin question announcement

  • Aborting a Thread.
    R Ronni Marker

    Not really an option waiting. So need to kill the thread one way or another. I know about Control.Invoke, but well, dosn't really help me on ending the thread before it is completed. Ronni

    C# windows-admin question announcement

  • Aborting a Thread.
    R Ronni Marker

    Hi I have the following code that is updating an dropdown box with information Active Directory information - this below will show Domain Controllers btw. But I am trying unsuccessfully to cancel an existing running thread if one exist already. this is mainly because sometimes a thread can be running indefinitely and need to abort that, or if another thread is called that need to update the same dropdownbox. Anyway are there any out here who could explain how I could abort an running thread?

        private void ThreadDC()
        {
    
            Thread TRDomainC = new Thread(ThreadingDC);
            if (TRDomainC.IsAlive)
            {
                TRDomainC.Abort();
            }
            TRDomainC.SetApartmentState(ApartmentState.STA);
            TRDomainC.Start();
        }
    
        private void ThreadingDC()
        {
            comboBox1.Items.Clear();
            try
            {
                if (comboBoxDomains.SelectedIndex >= 0 && comboBoxDomains.SelectedIndex != -1)
                {
                    foreach (string dc in domainInfoComponent\[comboBoxDomains.SelectedItem.ToString()\])
                    {
                        comboBox1.Items.Add(dc);
                    }
                    lastIndex = comboBoxDomains.SelectedIndex;
                    comboBox1.SelectedIndex = 0;
                }
            }
            catch
            {
                lastIndex = 0;
                comboBox1.SelectedIndex = -1;
            }
        }
    
    C# windows-admin question announcement

  • C# Datagridview
    R Ronni Marker

    Man.... Your right. Thanks, had been staring myself blind at what I already knew. Cheers, Ronni

    C# database csharp help question announcement

  • C# Datagridview
    R Ronni Marker

    Hi, I have a datagridview with a combobox. to find out when the combobox have changed values i included the following code

        private void dataGridView1\_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            ComboBox cbo = e.Control as ComboBox;
            if (cbo != null)
            {
                cbo.SelectionChangeCommitted += new EventHandler(cbo\_SelectionChangeCommitted);
            }
        }
    
        private void cbo\_SelectionChangeCommitted(object sender, EventArgs e)
        {
                MessageBox.Show(((ComboBox)sender).Text.ToString());
        }
    

    But the problem for me is that I realised that the messagebox gets triggered once for the first time i change a value in a row. But the second time i change value it gets triggered twice, third time it gets triggered trice and so furth. So, I was wondering if there is any way to only trigger the SelectionChangeCommitted once every time a user changes the combobox value? It will be a rather large number of rows, and if a user updates 200 rows, then it will mean that SelectionChangeCommitted will be triggered 200 times at the end and I can't have that as the messagebox should be replaced with a webservice that will update a value in a database at runtime. Any suggestion would be appreciated.

    C# database csharp help question announcement

  • quick combobox question
    R Ronni Marker

    nah can't really use that solution, then I wouldnt be able to use SelectedValue to get the current selected value and would have to rewrite too much code as I then couldnt load the combobox values elsewhere. but thanks for the effort.

    C# question tutorial

  • quick combobox question
    R Ronni Marker

    it's 00:30 and I lost my mind in a few beers, came home and would do some coding before I hit the showers, but now I forgot an important part... I remember how to add values and text to a combobox via a datasource, but can any remember how to add both text and value in a static way? ie. Combobox1.Items.Add(new ????("text","value")); yes, yes I know, don't code drunk.

    C# question tutorial

  • load combobox values into datagrid combobox
    R Ronni Marker

    ah forgot to drop in my code....

            frm\_Rights frmRights = new frm\_Rights();
            if (toolStripComboBox1.Text.ToString().Length != 0)
            {
                frmRights.label1.Text = toolStripComboBox1.Text.ToString();
                frmRights.dataGridView1.Columns\[1\].HeaderText = "User Name";
                //
                frmRights.dataGridView1.Rows.Add("", "user1", "16-08-1971", "16:00:00");
                frmRights.dataGridView1.Rows.Add("", "user2", "24-08-1983", "12:00:00");
                BindingSource bindCombo = new BindingSource();
                bindCombo.DataSource = toolStripComboBox1.Items;
    
                DataGridViewComboBoxColumn datagridCombo = new DataGridViewComboBoxColumn();
                datagridCombo.HeaderText = "Hello";
                datagridCombo.DataSource = bindCombo;
                frmRights.dataGridView1.Columns.Add(datagridCombo);
    
                frmRights.ShowDialog(this);
    
            }
    

    The above code works well fine enough - only with the exception that it dont load the content into column 0 but just add a new column onto the datagridview.

    C# json tutorial question

  • Visual Studio only displaying HTML instead of Design View
    R Ronni Marker

    Yea i got that too once in a while - basically due to an error in the code. What you could do was to close the form, compile the application and the open the form again. That works for me.. sometimes. Other option is to go into the designer mode and find the reason to the error - most often for me is that there is a reference to an image that is removed and is still referenced in that specific form or like. /Ronni

    C# csharp question html visual-studio winforms

  • load combobox values into datagrid combobox
    R Ronni Marker

    Hi all, I have a datagrid with 4 columns, 1st column is a combobox named "clmOptionNames" where i need to load the values from an combobox named "toolStripComboBox1" who is located outside the datagridview, the rest of the datagrid have values from a webservice and is loaded through the datasource. Is there anyone who know how to get the content from one combobox and then insert it into a datagridview combobox? the combobox is located at column 0 in the datagridview.

    C# json tutorial question

  • Minimize to tray bar [modified]
    R Ronni Marker

    Did a small change

            RegistryKey masterKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\\\Policies\\\\OTM");
            if (masterKey != null)
            {
                if (masterKey.GetValue("Serial").ToString().Length == 36)
                {
                    textBox1.Text = masterKey.GetValue("Serial").ToString();
                    textBox1.Enabled = false;
                    **this.WindowState = FormWindowState.Minimized;**
                    this.Hide();
                }
                else
                {
                    textBox1.Enabled = true;
                    this.StartPosition = FormStartPosition.CenterScreen;
                    this.WindowState = FormWindowState.Normal;
                    this.Show();
                }
            }
    

    plus included this:

        private void Form1\_Resize(object sender, EventArgs e)
        {
            if (WindowState == FormWindowState.Minimized)
            {
                Hide();
            }
        }
    

    It is far from beautiful but it works for now...

    C# windows-admin help question

  • Minimize to tray bar [modified]
    R Ronni Marker

    sorry i didnt mean the tray bay, but it is shown minimized in the left corner just above the traybar ifi i force the app to start minimized. ShowInTaskbar is already set to false.

    C# windows-admin help question

  • Minimize to tray bar [modified]
    R Ronni Marker

    Hi all, writing a small app that reads a registry setting and based on the content on that, should either show the form or hide it in the tray bar.

            RegistryKey masterKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\\\Policies\\\\OTM");
            if (masterKey != null)
            {
                if (masterKey.GetValue("Serial").ToString().Length == 36)
                {
                    textBox1.Text = masterKey.GetValue("Serial").ToString();
                    textBox1.Enabled = false;
                    this.Hide();
                }
                else
                {
                    textBox1.Enabled = true;
                    this.StartPosition = FormStartPosition.CenterScreen;
                    this.WindowState = FormWindowState.Normal;
                    this.Show();
                }
            }
    

    unfortunately the window always stays open. Anyone who have a quick tip to what Im missing? I tried to include this.WindowState = FormWindowState.Minimized;, but that just minimized to app, but didnt hide it in the tray bar. - sorry writing error here. Meant didnt hide the form at all. At best it gets to be minimized in the lower left corner.

    modified on Friday, November 6, 2009 4:27 AM

    C# windows-admin help question

  • Treeview in a thread [modified]
    R Ronni Marker

    Thanks!, will read it. Can see that the more I get to know about C#, the more I have to read up on. *Damn*. :)

    C# help question

  • Treeview in a thread [modified]
    R Ronni Marker

    Man, so simple and yet so beautiful... Thanks buddy. Btw. implemented it but found out that when running it in a thread it gets added trice. Running it outside the thread will only added to the treeview once as it should. Been going over the code but couldnt really see anything that should trigger the thread 3 times, so wondered if that had something to do with the invoke function?

    C# help question

  • Treeview in a thread [modified]
    R Ronni Marker

    Well it do take some time for the Webservice to finish. Especially when my server is located in California and some users will access this application in New Zealand - and that can be far, far, far away when im messing around with applications that don't play well with latency. I am not asking you to do the code for me, but do you have some examples on how to marshal the loop when using the Invoke or BeginInvoke? Cheers, Ronni

    C# help question

  • Treeview in a thread [modified]
    R Ronni Marker

    btw I did have a look at the article "Populating TreeView on a Background Thread" but didnt give me any clues on how i got out of my error.

    C# help question
  • Login

  • Don't have an account? Register

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