How do I … modify the appearance of a Windows.Forms.TableLayoutPanel at run-time

http://social.msdn.microsoft.com/Forums/en-US/vbpowerpacks/thread/ad57487d-d7e0-4131-a388-cc3815809033/

The following adjusts the column width

Me.TableLayoutPanel1.ColumnStyles(0).Width = 10.0

The following gets the actual control. Making this invisible, leaves the table cell in place, same size.

Me.LayoutPanelGraph.GetControlFromPosition(colIndex, rowIndex).Visible = False

In my own code this is seen in SRS.Windows.Forms.ListBoxFilter

How do I hide missing data values in DataVisualization.Charting.Chart e.g. Saturdays and Sundays

 

If data is missing for say days of weekend then the chart will by default still include these dates in the X values so there will be a not pretty gap. This can be corrected with:

Series.IsXValueIndexed = True

How do I set the DataVisualization.Charting.Chart Column Gap

The column gap is set on the:

Chart > Series > Misc > Point Width – default = 0.8 for no gap use 1

DataVisualization.Charting Cursors, Zooming, and Scrolling (Chart Controls)

 

I like the Zooming and Scrolling features of these Charts but find it difficult to find in the Chart Control. It is at:

Chart Areas > CursorX >

IsUserEnabled = True
IsUserSelectionEnabled = True

http://msdn.microsoft.com/en-us/library/dd456730

 

 

Click-Once – The application binding data format is invalid

 

Remove files from %userprofile%\AppData\Local\Apps\2.0\

LINQ and Entity Framework with DbContext – Convert Anonymous type to Strongly Typed – Bind to ListBox

[ Personally I have a sample of this in EFSample1.sln ]
To convert anonymous type to strongly typed, you can add a class that does what you want, then Select New … with {.ID = …}
This allows you to say get data from more than one table and still have a strongly typed output. Will not be updateable.

To fill a ListBox use

Imports System.Linq ‘if namespace not already imported

See http://wp.me/p17IS4-9S

Dim result = …GetEmployees
ListBox.DataSource = result.ToList

To save on setting the DisplayMember use .ToString in the class

Public Class EmployeeList
Property ID As Integer
Property FullName As String

Overrides Function ToString() As String
Return FullName
End Function

End Class

Public Class EmployeeEF

Private context As New EFWinFormsDBContext.TestEFIEntities

Function GetEmployees() As System.Linq.IQueryable(Of EmployeeList)

Dim result = From emp As Employee In context.Employees Join con As Contact In context.Contacts On emp.EmployeeID Equals con.ID Order By con.FullName
Select New EmployeeList With {.ID = emp.EmployeeID, .FullName = con.FullName}

Return result

End Function

End Class

Forms-Based Authentication with SQL Azure

 

Following is quite useful

http://msdn.microsoft.com/en-us/library/windowsazure/hh508981.aspx

I was able to get this to work without a Windows Azure Project

Worked on site. However the role manager did not wok

http://stackoverflow.com/questions/5541868/problem-with-your-selected-data-store-on-the-asp-net-website-administration-tool

Changed following and it worked
<roleManager enabled=”true”>

 

 

Deleting an ASP.Net azure hosted website using Entity Framework can potentially delete the linked database

I had a database on Azure that was being updated using Windows Forms. I then created an ASP.Net MVC application using EF to work against the same database. However I following a tutorial which used Code First

http://www.windowsazure.com/en-us/develop/net/tutorials/web-site-with-sql-database/

This would not publish until I used Nu-Get to:

enable-migrations

However I think I then used code first migrations on publish. However I published the website with high credentials and wanted to change the credentials to lower. Could not see how to do this in Azure, so deleted the website. At this point the database disappeared without warning.

This is why the last posts have been about SQL Azure backup. However recovered using on-site data and re-created database.

Microsoft support helped with the ASP.Net so:

enable-migrations

Check the file created, but do not check the box on publish.

Tested by deleting the Website – This then asked if you wanted to delete the linked database. Answer: No. Database stays ok.

How do I … change Config ConnectionString at runtime

See code below


Public Class RuntimeConnection

Const ConStringSettingsName = "MyEntitiesName"

Sub SetRuntimeConnection(UserNameValue As String, PasswordValue As String)
Dim currentConString = ConfigurationManager.ConnectionStrings(ConStringSettingsName).ConnectionString
Dim myWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~")
Dim builder As New EntityClient.EntityConnectionStringBuilder(currentConString)
Dim sqlConStrManager As New SqlClient.SqlConnectionStringBuilder(builder.ProviderConnectionString)
sqlConStrManager.UserID = UserNameValue
sqlConStrManager.Password = PasswordValue
builder.ProviderConnectionString = sqlConStrManager.ConnectionString
myWebConfig.ConnectionStrings.ConnectionStrings(ConStringSettingsName).ConnectionString = builder.ConnectionString
myWebConfig.Save()
ConfigurationManager.RefreshSection("connectionStrings")
'Dim msg = String.Concat(sqlConStrManager.ConnectionString, vbCrLf, vbCrLf, builder.ConnectionString, vbCrLf, vbCrLf, _
' myWebConfig.ConnectionStrings.ConnectionStrings(ConStringSettingsName).ConnectionString)
'MsgBox(msg)
End Sub

End Class

Also see below


Imports System.Configuration

...

Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
config.ConnectionStrings.ConnectionStrings("myEntities").ConnectionString = value
config.Save()
ConfigurationManager.RefreshSection("connectionStrings")
'MsgBox(config.ConnectionStrings.ConnectionStrings("myEntities").ConnectionString)

.

 

End.

ASP.Net publish to Azure with Database and control of Start Page

Followed

https://www.windowsazure.com/en-us/develop/net/tutorials/web-site-with-sql-database/

There was a warning on publish page 3, which mentioned code-first migrations must be enabled. After web-search I realised I needed to upgrade to a higher version of EntityFramework which has System.Data.Entity.Migrations

Used Visual Studio > Tools > Library Package Manager > Package Manager Console

PM> install-package EntityFramework -Pre

PM> enable-migrations

will then publish. Although now up, the sites page is “This web site has been successfully created. There’s nothing here yet, but Windows Azure makes it simple to publish content with GIT, TFS, FTS or your favorite development tool”

If go directly to a page I know exists it does take me there, (or in my case redirects to login)

http://xamlgeek.net/2010/11/19/start-page-in-azure/

During development this of course wasn’t an issue – I just right clicked the page I wanted as startpage as selected “Set as Start Page”.

When I deployed to Azure the start page wasn’t recognized. To set the start page in Azure it is necessary to do one of two things: 1) Implement a start page called “Default.aspx” or 2) specify the start page in the web.config file:

2010-11-19_002433

Setting the defaultDocument value in the web.config fixed my issue.