Showing posts with label VS 2008. Show all posts
Showing posts with label VS 2008. Show all posts

02 November 2009

 

Visual Basic Power Packs 3.0 have very cool same as we web application, named DataRepeater.

lets do some cool stuff with DataRepeater control.

  • Add Data source.
  • Add Combobox in datarepeater control
  • Hide show controls runtime in datarepeater control

 

DataRepeater

See the above image, We have a button, a DataRepeater control and in data  repeater control we have a textbox, a combo box and a label which will hide and show runtime by selecting value of combobox.

So lets start, how to do this.

 

Create a class to save data, I am not using any DataTable for this example.

public class data1 : List<data1>
    {
        private string mName;
        private string mDdlValue;

        public data1()
        {
        }

       public string Name
        {
            get { return mName; }
            set { mName = value; }
        }

        public string DdlValue
        {
            get { return mDdlValue; }
            set { mDdlValue = value; }
        }
    }
}

In above code we have two property “Name” and “DdlValue” and it is inherited with “List” to bind data.

Now lets bind that controls with data1 class

I will use Form_Load  event to do this.

/// <summary>
/// data1 variable declaration in Form Class
/// </summary>
private data1 objData = new data1();

 

private void Form1_Load(object sender, EventArgs e)
{
    ///Bind Textbox with Name property
    tbName.DataBindings.Add(new System.Windows.Forms.Binding("Text", objData, "Name"));

    ///Bind Combo box with DdlValue property
    comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", objData, "DdlValue"));
}

 

And databind “objData” to DataRepeater1 control, I will use button click event to do this.

private void button2_Click(object sender, EventArgs e)
{
    objData.Add(new data1());
    dataRepeater1.DataSource = null;
    dataRepeater1.DataSource = objData;
}

 

Ok to now when  you will click on button2, it will add new item in “objData” and then, bind it to dataRepeater1 control.

But still we have to add item in combobox, So we need to use “ItemCloned” event to do this.

private void dataRepeater1_ItemCloned(object sender, Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs e)
{
    ComboBox c1 = (ComboBox)e.DataRepeaterItem.Controls.Find("comboBox1", true)[0];

    c1.Items.Add("sa1");
    c1.Items.Add("sa2");
    c1.Items.Add("sa3");
    c1.Items.Add("sa4");
    c1.Items.Add("sa5");
}

you can see that now there are 5 item in combo box.

and finally let hide and show a label control dynamically, Here in example the logic is, when use select “sa2” from combo box it will show the label else it will be hide.

We have to use DrowItem event to do this.

private void dataRepeater1_DrawItem(object sender, DataRepeaterItemEventArgs e)
{
    if (objData[e.DataRepeaterItem.ItemIndex].DdlValue == "sa2")
    {
        ((Label)e.DataRepeaterItem.Controls.Find("label2", true)[0]).Text = "this is second option";
    }
    else
    {
        ((Label)e.DataRepeaterItem.Controls.Find("label2", true)[0]).Visible = false;
    }
}

So this is good to run our program, but one more thing, If you want to hide show label directly when use change value from dropdown list, you have to add SelectedIndexChanged to combobox1.

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    ComboBox cbo = ((ComboBox)(sender));

    DataRepeaterItem prnt = (DataRepeaterItem)(cbo.Parent);

    Label objLavel = ((Label)(prnt.Controls.Find("Label2", true)[0]));
    if (cbo.SelectedIndex == -1)
    {
        return;
    }
    if (cbo.Text == "sa2")
    {
        objLavel.Visible = true;
        objLavel.Text = cbo.Text;
    }
    else
    {
        objLavel.Visible = false;
    }
}

So just press F5 to run this program.

So this is a very simple example to work with dataRepeater control, you can utilize your requirement in it and have some cool looking information in your window application!

19 June 2009

Writing inline documentation is very useful but many developers are excusing that its is taking to much time to write down comments, Friends here is a tool for you which will write XML documentation in your C# or VB.net code vary quickly.

This tool is works with Visual Studio 2005, 2008.

GhostDoc is a free Visual Studio extension that automatically generates XML documentation comments.

Its allows us to add quick documentation for :
  • Methods
  • Properties with its data type
  • Parameters Name
  • Variable Name
See the below example :


Just right click on clock on the name of the function, where will be a menu with "Document this".
Click on it and it will write word quickly documentation for you.

See here the result:



So GhostDoc is very useful tool,

happy codding.

20 September 2008

Download Visual Studio 2008 SP1.

and also read about that what new in Visual Studio 2008 SP1 from here in power point presentation and also in text format here.

18 September 2008

Download .NET Framework 3.5 Common Namespaces and Types Poster in PDF format.


07 August 2008

Here is a tool to change Visual Studio Theme (Coding Style - Color etc.)



Just select color, click on "Refresh" button to see the effect, and click on "Create" button to download "vssettings" fil.

Open Visual Studio and user "Import Export Setting..." from "Tools" men.

30 July 2008

Get Master Pages tutorials from ASP.Net web site,

There are 10 tutorials what are very useful to learn and also for good pectic for coding. Specifying the Master Page Programmatically and Nested Master are realy useful.

Click Here

There is also available code C# and VB to download.

22 July 2008

How to Load User Control Dynamically and also access it's property dynamically.

support u have two user control

User Control "a0"


%@ Control Language="C#" AutoEventWireup="true" CodeFile="a0.ascx.cs" Inherits="UserControlTest_a0" %

asp:TextBox ID="TextBox1" runat="server">asp:TextBox>

br /


asp:Button ID="Button1" runat="server" Text="Button" /


And there is a property to something for text value in it's CS file.

public string TextValue
{
get { return TextBox1.Text; }
set { TextBox1.Text = value; }
}


Now User Control "a1"

%@ Control Language="C#" AutoEventWireup="true" CodeFile="a1.ascx.cs" Inherits="UserControlTest_a1" %


%@ Register src="a0.ascx" tagname="ASP" tagprefix="ASP" %


Now in the page load event of this second user control I want to load "a0" user control and also want to set it's "TextValue" property.

protected void Page_Load(object sender, EventArgs e)
{
///Load Control
UserControl ucDynamic = (UserControl)LoadControl("a0.ascx");

///Add User control to the page
this.Controls.Add(ucDynamic);

///Change Property value for newely added user cotrol
///here "UserControlTest" is the name of the folder in my test web site, user have to change it
((UserControlTest_a0)ucDynamic).TextValue = "saAction";
}


It mans there are two user controls "a0" and "a1", Using "UserControl" we can add user control dynamically and to access it's property we have to convert that variable in to our user control.


05 July 2008

Don't type too much in aspx page!

just write

asp: Label

and press enter

asp:Label runat=”server” id=”asp_Label2943″ />

Download this add-in from here

Unzip download and copy to :

C:\Documents and Settings\[USER]\Application Data\Microsoft\MSEnvShared\Addins

if you did not found "MSEnvShared" and "Addins" folder then create it manually.

20 February 2008

Download some learning Video for ASP.NET 3.5 from MSDN.

You can also download source code for them.

There are more then 100 video series for ASP.NET related technology.

13 January 2008

Did you started to learn new features of Visual Studio 2008?

  • What's New in Microsoft Visual Studio 2008
  • Microsoft LINQ
  • Microsoft ASP.NET AJAX
  • Microsoft Silverlight.
Download eBook of this new version of Visual Studio from Microsoft learning center.

25 November 2007

ASP.NET site have some new video series.

Download learnig video ASP.NET 3.5 and Visual Studio 2008. And Click here to download Linq videos.

28 July 2007

Defy All Challenges is Microsoft site, to get graphical representation using flash technology.


Get information about Office 2007, Vista, Web development and Visual Studio Team System.

Also have some fun there, creating your own cartoon animation.


click here for HTML version.

27 July 2007

Still, Just to days a go I have complete to download Visual Studio 2008 Beta 1, and do day I found that Visual Studio 2008 Beta 2 is released,

So, once again, I have started to download this new version.

26 July 2007

Finally after two weeks hard download, I have "Orcas".

Download Visual Studio Code Name “Orcas” Beta 1

Here are some screen shots:

Select .Net Framework version direct form New project dialogbox.


Create C# and Visual Basic WPF Application


Office 2007 Workbook, document direct in Visual Studio as wall as Template and Add-In.


Office 2003 Workbook, document direct in Visual Studio as wall as Template and Add-In.


Worlflow Application

There are many feature in this version which was available in Team edition of Visual Studio 2005, now they are including in this version of "Orcas".

So, I have started to learn Visual Studio 2008, What about U?