Posts

Showing posts from February, 2016

MFC getting the current date and time

I've been updating some older MFC/C++ applications and I found I needed to get the current system time. There's a way in the Win32 API but it's clunky. MFC gives you a simple way. CTime t = CTime :: GetCurrentTime (); CString s = t . Format ( "%m%d%Y" ); The Format method can take a wide variety of parameters. See this MSDN link

ASP.NET dynamically load AJAX toolkit accordion panes

I love the Accordion pane from the AJAX toolkit, but I've found myself needing to dynamically add accordion panes to it. To do this you need to some work on the back end. The following code loops through a DataSet and dynamically creates a Label control for the header and content. It then adds those controls to a new AccordionPane and then add it to your Accordion. for ( var i = 0; i < ds.Tables[10].Rows.Count; i++ ) { Label lblContent = new Label(); lblContent.ID = Guid.NewGuid().ToString(); Label lblTitle = new Label(); lblTitle.ID = Guid.NewGuid().ToString(); lblTitle.Text = ds.Tables[2].Rows[i + 1][1].ToString(); lblContent.Text = ds.Tables[10].Rows[i][1].ToString(); AjaxControlToolkit.AccordionPane pane = new AjaxControlToolkit.AccordionPane(); pane.ID = Guid.NewGuid().ToString(); pane.HeaderContainer.Controls.Add( lblTitle ); pane...