That worked great! Thank you both! *sigh of relief*
Mikan23
Posts
-
Accessing Dynamically Added User Controls -
Accessing Dynamically Added User ControlsIts getting closer, I have added them and can access them to a point using the following:
MonitorTab monitor = new MonitorTab(); monitor.Name = "Monitor" + MonitorTabs.TabPages.Count.ToString();
But I still can't access that control except using a foreach looping through the controls on the tab, which doesn't allow me to access the timer. Any suggestions? -
Accessing Dynamically Added User ControlsThat makes sense but I've never tried that before (somewhat new at this), could you demonstrate please? This is my current code.
TabPage newMonitorTab = new TabPage(TabTitle); MonitorTabs.TabPages.Add(newMonitorTab); MonitorTab monitor = new MonitorTab(); newMonitorTab.Controls.Add(monitor);
Thanks! -
Accessing Dynamically Added User ControlsSorry I wasn't clear enough. On each tab is a user control called Monitor. So if I have three tabs, then there are three Monitors. Monitor has various elements including a timer, a datagridview, a treeview, etc... since they are part of the same user control, they are all named the same. So for example, I want to set refreshTimer on Monitor on tab 2 (the currently selected tab). How would I access that refreshTimer. I have tried the following without success
MonitorTabs.SelectedTab.Monitor.refreshTimer MonitorTabs.SelectedTab.refreshTimer MonitorTabs.TabPages[MonitorTabs.SelectedIndex].Monitor.refreshTimer
Thanks -
Accessing Dynamically Added User ControlsOn my form (MainWindow) I have a TabControl called MonitorTabs. I programmatically add a tab to it for each user I want to monitor. Then I add a user control called Monitor that contains a group of controls including a timer (RefreshTimer) to that tab. From MainWindow, I call a function that needs to reset the interval on RefreshTimer on the currently selected tab. The number of RefreshTimers is dynamic, one for each User Control/Tab, and I don't know how to access any of them let alone the one that is currently selected. The timer is set to public, and still nothing shows up. Can anyone help?
-
Accessing parts of identical use controlsEither I don't understand your solution or I didn't explain myself very well. It works like this. on my form (MainWindow) I have a TabControl called MonitorTabs. I programmatically add a tab to it for each user I want to monitor like so:
TabTitle = FirstName + " " + LastName; TabPage newMonitorTab = new TabPage(TabTitle); MonitorTabs.TabPages.Add(newMonitorTab);
Then I add a user control called Monitor that contains a group of controls including a timer (RefreshTimer) to that tab like so:Monitor monitor = new Monitor(); monitor.Size = newMonitorTab.Size; monitor.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; monitor.UserID = UserID; newMonitorTab.Controls.Add(monitor);
Then the function ends and other things happen. From the menu in MainWindow, I call a function that needs to reset the interval on RefreshTimer on the currently selected tab. There may be three RefreshTimers, one on each User Control/Tab, and I don't know how to access any of them let alone the one that is currently selected. The timer is set to public, and still nothing shows up. I hope this explains it better. Thanks for any forthcoming help -
Accessing parts of identical use controlsI have a TabControl, and tabs can be dynamically added for users. When a tab is added, a user-control is added to that tab. So each tab has an identical user control, and each control is made up of a group of identical controls. I need to access those controls, in this case, a timer from the main window, but I cannot just use the name of the timer "refreshTimer". How would I access them? I have tried
tabcontrolname.tabpages[selectedIndex].usercontrolname.refreshTimer.Start();
along with several other variations, but none of them have worked so far. Any suggestions? -
How to Add Data to a dataset and write to an xml fileI have a dataset that I read from an xml file using
DataSet.ReadXml(fs);
I then add to the dataset and rewrite the xml file using the following:DataRow newrow = mf.quotesDataSet.Tables["quote"].NewRow(); newrow["thequote"] = quoteInput.Text; newrow["speaker"] = speakerInput.Text; newrow["origin"] = originInput.Text; newrow["image"] = "test.jpg"; mf.quotesDataSet.Tables["quote"].Rows.Add(newrow); mf.quotesDataSet.WriteXml(fw);
It does add the data, however, it adds it outside the main xml hierarchy. For example, instead of:<rss> <channel> <quote><thequote>text</thequote></quote> <quote><thequote>text</thequote></quote> <quote><thequote>new text</thequote></quote> </channel> </rss>
it writes to the file as:<rss> <channel> <quote><thequote>text</thequote></quote> <quote><thequote>text</thequote></quote> </channel> </rss> <quote><thequote>new text</thequote></quote>
how do I make the added rows to the dataset write into the proper hierarchy? -
Dataset WriteXML places rows added to dataset outside of main nodesI have a dataset that I read from an xml file using
DataSet.ReadXml(fs);
I then add to the dataset and rewrite the xml file using the following:DataRow newrow = mf.quotesDataSet.Tables["quote"].NewRow(); newrow["thequote"] = quoteInput.Text; newrow["speaker"] = speakerInput.Text; newrow["origin"] = originInput.Text; newrow["image"] = "test.jpg"; mf.quotesDataSet.Tables["quote"].Rows.Add(newrow); mf.quotesDataSet.WriteXml(fw);
It does add the data, however, it adds it outside the main xml hierarchy. For example, instead of:<rss> <channel> <quote><thequote>text</thequote></quote> <quote><thequote>text</thequote></quote> <quote><thequote>new text</thequote></quote> </channel> </rss>
it writes to the file as:<rss> <channel> <quote><thequote>text</thequote></quote> <quote><thequote>text</thequote></quote> </channel> </rss> <quote><thequote>new text</thequote></quote>
how do I make the added rows to the dataset write into the proper hierarchy? -
Binding Dataset to DataGridViewIts determined to stay with the fields in the dataset, so I tried your second suggestion from the original and renamed the fields in the dataset temporarily. This worked on the datagridview just fine, many thanks!
-
Binding Dataset to DataGridViewI'm working with the new Visual C# Express beta and the latest of the .Net 2 version. Unfortunately, they have replaced datagrid with datagridview, and datagridtablestyle does not seem to have a new version. Unfortunately, they also have not provided any documentation that I can understand for achieving the same effects. Any other thoughts? Thanks for the help either way.
-
Binding Dataset to DataGridViewI am attemping to bind the data from an xml file into a datagridview. I have achieved this via the following code:
quotesDataSet.ReadXml(Properties.Settings.Default.XmlQuoteFile); quoteGrid.DataSource = quotesDataSet; quoteGrid.DataMember = "quote";
This automatically binds the four elements of the quote parent into four rows. However, from that point on, I cannot rename the header rows or control them in any way. I've tried everything from attempting to assign a datagridtablestyle, to simply using quoteGrid.Columns[1].HeaderText = "Text"; Can anyone provide me with a working example of how to achieve this?