Showing posts with label Microsoft. Show all posts
Showing posts with label Microsoft. 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!

02 April 2008

This is one kind of RSS Reader software.

Using MSDN Reader we can brows MSDN Magazine very easily.

This is available on WidowsClient.net







Download MSDN Reader

01 December 2007

You may have seen Microsoft Download Center so many times.


But now there is a new look:



Visit Microsoft Download Center Beta!

17 September 2007

See MSDN Magazine in a book format.

Click Here.


Have fun with moving page...


There is also another magazine for "Dr. Dobb's Journal".

02 March 2007

i found that many developers even those how have experience, does n't know many short cut keys which are realy usefull for them.

here are some short cut key:

Just Press WinKey + R and type


devenv Visual Studio Development Environment
SqlWb SQL Server Management Studio
dexplore Microsoft Visual Studio Documentation
profiler90 SQL Server Profiler
control Control Panel


some other

notepad NotePad
calc Calcularor
mapaint Microsoft Paint
pbrush Microsoft Paint
wordpad WordPad
winword Microsoft Office Word
excel Microsoft Office Excel
powerpnt Microsoft Office Power Point
msaccess Microsoft Office Access


if you know any other short cut key please put it in to comment.

07 December 2006

hi, Microsoft Have started new Community Content in MSDN,

this is for MSDN2, you can add your own notes, code, comment in MSDN,

just use have to give a user name to register and you can access it like i have,

you can find RSS feed also Click Here

you can add a Title and write your code or comment there with simple HTML format like
font, code style, bold, italic, underline, teb indent ect.


Click here to see my ID

register here and share your knoledge.

13 November 2006

You will find here Microsoft Feeds Directory.

  • orange rectangle a feed icon
  • with the letters XML
  • or RSS
all most all RSS for Microsoft are available here.

Click here to find detailed information for RSS Feeds. Where you will find some RSS Reader sites and applications. and also that how it's help us.

A to Z Microsoft Feed

Find detailed information for RSS on Wikipedia, Open XML Developer, RSS-Specifications

17 October 2006

hurry up, to download Microsoft e-Learnign Course.

click Here where you found details

there is all most all Microsoft Office 2007 course avalable.

remember that it is limited for 90 Days

i fond this information form
Microsoft Higher Education - Mid-Atlantic

16 October 2006

you can found here all download list avalable in Microsft download center.

like A to Z :

15 October 2006

27 September 2006

this is a grate opportunity to create blog in MSDN for India.

find more details on here.

14 September 2006

find almost all import leader blog.
Click here to open the page.

there are many many leader blog path avalable.

like
Visual Studio Team System Foundation Server
Visual Studio
.NET Compact Framework

and many other
read there idea