Posts

Donate

ListView In WPF With Alternating Row Colors

Here's how to alternate the row colors for a WPF ListView control using a Converter class and Triggers. Converter Class: 1 2 3 4 5 6 7 8 9 10 11 12 13 public class AddressTargetConverter : IValueConverter { public object Convert( object value , Type targetType, object parameter, CultureInfo culture) { return ( value .ToString().Equals(parameter.ToString())); } public object ConvertBack( object value , Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } XAML: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 <Window.Resources> <y:AddressTargetConverter x:Key= "AddressTargetConverter" /> </Window.Resources> <Grid> <StackPanel> <ListView ItemsSource= "{Binding PersonCollection}" > <ListView.It...

ASP.NET GridView Control CRUD With Bootstrap

Image
Here's a simple CRUD application using ASP.NET GridView control with Twitter Bootstrap as it's css class reference. The code sample used is in VB.NET. Create: Update: Delete: ASPX markup: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 <div id= "Container" > <div id= "GridContainer" > <div id= "LabelContainer" > <asp:Label ID= "lblHeading" runat= "server" Text= "ASP.NET GridView CRUD with Bootstrap (VB.NET)" > </asp:Label> ...

ASP.NET GridView RowCommand Event Firing Twice

This issue happened when I migrated an asp.net 3.5 website to an asp.net 4.5 website. Upon clicking Add or Delete linkbuttons in the GridView, the RowCommand event fires twice. After googling for hours, I found a solution that is to remove the Handles GridView1.RowCommand in the event declaration. The code below does not work (event fires twice) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Protected Sub GridView1_RowCommand ( ByVal sender As Object , ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) _ Handles GridView1.RowCommand If e.CommandName.Equals( "AddNew" ) Then Dim txtNewName As TextBox txtNewName = CType (GridView1.FooterRow.FindControl( "txtNewName" ), TextBox) Dim cmbNewGender As DropDownList cmbNewGender = CType (GridView1.FooterRow.FindControl( "cmbNewGender" ), DropDownList) Dim txtNewCity As TextBox txtNewCit...

Find Checked Treenode In TreeView Control Using LINQ In VB.NET

Here's one way of searching through a treenode using LINQ. Assuming that the search criteria is a List or array object. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Public Class Form1 Public Shared mat As List( Of String ) = Nothing Private Sub Form1_Load (sender As System.Object, e As System.EventArgs) Handles MyBase .Load mat = New List( Of String ) mat.Add( "Books" ) mat.Add( "VB" ) mat.Add( "Drinks" ) mat.Add( "Food" ) mat.Add( "Tea" ) mat.Add( "Chod" ) End Sub Private Sub Button1_Click (sender As System.Object, e As System.EventArgs) Handles Button1.Click If Not (mat Is Nothing ) Then For Each tn As String In mat If (tvMat.Nodes.Find(tn, True ).FirstOrDefault() IsNot Nothing ) Then If (tvMat.Nodes...

The type of one of the expression in the join clause is incorrect.Type inference failed in the call to GroupJoin In C#

Hi, I just tested on grouping two collections using GroupJoin approach in LINQ to XML. In the example, the two collections are Customers and Companies. In which, companies served as grouping for the customers. In simple terms, identify a customer of which company he or she belongs. The code below produced an error The type of one of the expression in the join clause is incorrect.Type inference failed in the call to GroupJoin. XElement companiesAndCustomers = new XElement( "CompaniesAndCustomers" , from company in companies join customer in customers on company equals customer.CompanyName into groupCompany select new XElement( "Company" , new XAttribute( "CompanyName" , company.CompanyName), new XAttribute( "Country" , company.Country), from subCustomer in groupCompany select new XElement( "Customer" , subCustomer.LastN...

Formatting ASP.NET Web Forms Panel as Bootstrap Modal Dialog

Here's how you make use of the asp.net panel container that will serve as modal dialog. During render, panel will be converted to div elements. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <asp:Panel ID= "pnlModal" runat= "server" role= "dialog" CssClass= "modal fade" > <asp:Panel ID= "pnlInner" runat= "server" CssClass= "modal-dialog" > <asp:Panel ID= "pnlContent" CssClass= "modal-content" runat= "server" > <asp:Panel runat= "server" class= "modal-header" > <button type= "button" class= "close" data-dismiss= "modal" > <span aria-hidden= "true" > &times; </span><span class= "sr-only" > Close </span> </button> ...

WIndows Forms Linear Gradients In C#.NET 2D

Image
Hi, Here's a simple demo using Linear gradients (Color Manipulation) in C#.NET Windows Forms. private int _rColor = 100; public int GenerateRGB( int cc) { int rt = 0; if (cc <= 255) { rt = Information.RGB(255, cc, 0); } else if (cc < 511) { rt = Information.RGB(255 - (cc - 255), 255, 0); } else if (cc < 766) { rt = Information.RGB(0, 255, cc - 511); } else if (cc < 1022) { rt = Information.RGB(0, 255 - (cc - 767), 255); } else if (cc < 1277) { rt = Information.RGB(0, 0, 255 - (cc - 1022)); } else { rt = Information.RGB(0, 0, 0); } return rt; } private void timer1_Tick( object sender, EventArgs e) { this .Refresh(); _rColor += 1; if (_rColor > 1500) { _rColor = 0; } } private void Form1_Paint( object sender, PaintEventArgs e) { Color color = new Color(); Random m_Rnd = new Random(); color = Color.FromArgb(255, m_Rnd.Next(0, 255), m_Rnd.Next(0, 255), m_Rnd.Next(0, 255)); using (LinearGradi...

Cannot connect to WMI provider. You do not have permission or the server is unreachable In SQL Server 2012

Image
Hello, When you click on SQL Server Configuration Tools after pc reboot, you might encounter an error stated by the title of this post. Given the following details OS: Windows 7 Enterprise 64 Bit Software: SQL Server 2012 Network Setup: Domain Controller The steps to resolve the issue is presented below: 1. Right click command prompt and select "Run as Administrator" 2. Type the following in the command prompt C:\ mofcomp "%programfiles(x86)%\Microsoft SQL Server\110\Shared\sqlmgmproviderxpsp2up.mof" (where 110 is the number) Note: For this command to succeed, the Sqlmgmproviderxpsp2up.mof file must be present in the %programfiles(x86)%\Microsoft SQL Server\number\Shared folder. Sample Error Message: Cheers! :)

ASP.NET Web Forms Using Master Page Not Found On Visual Studio 2012 IDE

When the RTM versions of Visual Studio 2012 were updated to version 4, I noticed that when you Add a New Item in an Asp.net website or project, "Web Form Using Master Page" has gone missing. I soon realized that Web Form Using Master Page is replaced with "Content Page" in the Add New Item Dialog. :)

Webbrowser Control Imitate Internet Explorer Behavior

Image
Hi, Lately, I was given a task from a client if I can update my VB.NET crawler scripts with a webbrowser control to show/render images of the crawled website to the control. Normally, I used the control just to obtain the web page source and then parse the necessary information. By default, the settings of the webbrowser control is IE7. After doing some reseach, I stumbled upon a solution by Noseratio on IE Feature Control Hacks . The documentation for browser emulation can be found on MSDN: MSDN Browser Emulation . I uploaded a sample VB.NET application here: WebBrowser Control Similar to IE Browser Sample Result: Cheers! :)

Donate