Free Download

Site Search

 

Top Download

Showing posts with label flex. Show all posts
Showing posts with label flex. Show all posts

Friday, July 4, 2008

Edit MS Flex Grid in Two Ways

Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Introduction

Hi all!

This is my second article on Code Project. This is about how to edit MS Flex Grid. I was using TextBox and ComboBox to edit flex grid at run time, for that I had to add reference of Microsoft.VisualBasic.Compatibility and some complex coding to move TextBox or ComboBox on grid. But this is good idea if some one wants to edit grid with some predefined itemsusing ComboBox.

But if you want to text than there is a simple way to do this; that is the use of Text property of MS Flex Grid Control.

Using the code

To edit MS Flex Grid without using TextBox we have to use .Text property and KeyPressEvent of MS Flex Grid Control.

 
Private Sub AxMSFlexGrid1_KeyPressEvent(ByVal sender As Object, ByVal e As AxMSFlexGridLib.DMSFlexGridEvents_KeyPressEvent) Handles AxMSFlexGrid1.KeyPressEvent

Select Case e.keyAscii

Case 30 To 136

AxMSFlexGrid1.Text += Chr(e.keyAscii)

Case 8

If AxMSFlexGrid1.Text <> "" Then AxMSFlexGrid1.Text = Mid(AxMSFlexGrid1.Text, 1, Len(AxMSFlexGrid1.Text) - 1)

Case 13 And AxMSFlexGrid1.Col <> 2

AxMSFlexGrid1.Col = 2

Case 13 And AxMSFlexGrid1.Col = 2

AxMSFlexGrid1.Rows = AxMSFlexGrid1.Rows + 1

AxMSFlexGrid1.Col = 1

AxMSFlexGrid1.Row = AxMSFlexGrid1.Row + 1

End Select

End Sub

In second techinque I have used a function name moveTextBox to move TextBox at appropriate posiotion and to sent enter text in Grid I have used .Textproperty of Grid control.

 
Private Sub moveTextBox()
TxtEntry.Visible = True
TxtEntry.Left = VB6.TwipsToPixelsX(AxMSFlexGrid2.CellLeft + VB6.TwipsToPixelsX(AxMSFlexGrid2.Left)) + 17
TxtEntry.Top = VB6.TwipsToPixelsY(AxMSFlexGrid2.CellTop + VB6.TwipsToPixelsY(AxMSFlexGrid2.Top)) + AxMSFlexGrid2.Top
TxtEntry.Width = VB6.TwipsToPixelsX(AxMSFlexGrid2.CellWidth)
TxtEntry.Height = VB6.TwipsToPixelsY(AxMSFlexGrid2.CellHeight)
TxtEntry.BringToFront()
TxtEntry.Focus()
End Sub

On TextBox's KeyDown event I have assigned TextBox's .Text property to Flex Grid's .Text property

 
Private Sub TxtEntry_KeyDownEvent(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TxtEntry.KeyDown
If AxMSFlexGrid2.Col = 1 Then
If e.KeyCode = Keys.Enter Then
AxMSFlexGrid2.Text = TxtEntry.Text
TxtEntry.Clear()
AxMSFlexGrid2.Col = 2
End If
End If
End Sub

On EnterCell event of Grid Control I have called this function.


Private Sub AxMSFlexGrid2_EnterCell(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxMSFlexGrid2.EnterCell
If AxMSFlexGrid2.Col = 2 Then
Call moveCombo()
If AxMSFlexGrid2.get_TextMatrix(AxMSFlexGrid2.Row, 2) <> "" Then
CmbEntry.Text = AxMSFlexGrid2.get_TextMatrix(AxMSFlexGrid2.Row, 2).ToString
Else
CmbEntry.Text = ""
End If
Else
CmbEntry.Visible = False
End If
If AxMSFlexGrid2.Col = 1 Then
Call moveTextBox()
If AxMSFlexGrid2.get_TextMatrix(AxMSFlexGrid2.Row, 1) <> "" Then
TxtEntry.Text = AxMSFlexGrid2.get_TextMatrix(AxMSFlexGrid2.Row, 1).ToString
Else
TxtEntry.Clear()
End If
Else
TxtEntry.Visible = False
End If
End Sub

Thanx And Happy Coding..

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

suresh suthar


Hi All.
I am Suresh Suthar from Mumbai India.
I am a Software Developer working in a private firm as a .NET developer.
I born and brought up in a small village Sewari in Rajasthan.
I started my carrier as a data entry operator in 2006. After that I started learning VB 6.0 and VB.NET 2005.
Now I am developing software using VB.Net 2005
and SQL Server 2000/2005.

Here you will some cool source code and a lots of stuff on
SQL Injection, Code Injection, Encription/Decription, Live project, Tutorials on VBScript,JavaScript,Cold Fusion, C#
and many more...

http://www.programmer2programmer.net/
Occupation: Web Developer
Location: India India


http://www.codeproject.com/KB/grid/EditMSFlexGrid.aspx

Simple Flex Tutorial

I've been learning Flex for a presentation at my local CFUG, and I'm actually quite impressed with how much you can do with so little code.

However, most of the Flex tutorials I have found are very long and over simplified, so I've created a simple blog reader in 23 lines of MXML code to use as a tutorial. Here's what our Flex Application will look like:

flex blog reader screen shot

How does the example work?

When you click the Load Blog Entries button my RSS feed entries are loaded into the datagrid. When you click on a row in the datagrid the corresponding entry is loaded into the text area.

Step 1 - XML and Application declaration

Start your XML file with a XML declaration, and an mx:Application tag:




Step 2 - Define your HTTPService

Our first step is to define the HTTPService that we will use to connect to my RSS feed. We will give an id of httpRSS so we can refer back to it.


Step 3 - Enclose your controls within a panel

A panel is simply a container to put controls (the DataGrid, TextArea, and Button) into. We are going to set some attributes on the panel as well, it should be pretty easy to figure out what they mean:


Step 4 - Define your DataGrid

We are using the DataGrid component to display the list of blog entries in my RSS feed, along with their date.

This step is probably the most complicated step because we have to bind our RSS xml data to the datagrid, and define an event handler when the rows are clicked.

In the attributes of the DataGrid we are using dynamic variables or expressions denoted by the curly braces {variable}.









Ok so there is a lot going on there, first so I'll break it down a bit:

width

We are setting the width dynamically based on the size of its parent panel reader, specifically we set it to be 15 pixels narrower than its panel.

dataProvider

In the dataProvider attribute we are binding the data for this grid to the result of our HTTPService named httpRSS. More specifically we want to bind each item tag in our XML file to a row in the datagrid. Since the item tags are inside the rss and channel tags we refer to it the array of items as httpRSS.result.rss.channel.item.

cellPress

Next we want to create an event handler that will display the contents of the description tag inside the item that is clicked on. Using the variable entries.selectedIndex we know which item was clicked on, and we can refer to the description (the entry body) of that item as: httpRSS.result.rss.channel.item[entries.selectedIndex].description.

Now we just need to set the value of our TextArea which we will define in the next step to the rss item description, so we simply assign that value to the htmlText property of the TextArea (whose name will be body).

columns

Now we need to define which columns we are to display in the datagrid. The columnName must match the tag name that we want it to correspond to.

Step 5 - Define the TextArea

Use the mx:TextArea tag to define the text area where the entry body will go:


Step 6 - Create a Button

Our last control to define is a Button which will simply tell the HTTPService to make the request.

In the click event handler we call the send() method on our HTTPService object.

Step 7 - Close Panel and Application

Simply close some tags, and your done!



One Caveat

Flex 1.5 uses a proxy to invoke HTTPService calls, and other remote service calls, and for security reasons the proxy will block the HTTP call. You add the RSS feed url (or simply http://*) to the proxy whitelist in your flex-config.xml. See this KB article for more info.

Complete MXML source code:
























Flex:Open Source

From Adobe Labs

Table of contents [hide]

Adobe to Open Source Flex

On April 26, Adobe announced strategic plans to move the development of Flex to an open source model.

Overview

Adobe is announcing plans to open source Flex under the Mozilla Public License (MPL). This includes not only the source to the ActionScript components from the Flex SDK, which have been available in source code form with the SDK since Flex 2 was released, but also includes the Java source code for the ActionScript and MXML compilers, the ActionScript debugger and the core ActionScript libraries from the SDK. The Flex SDK includes all of the components needed to create Flex applications that run in any browser - on Mac OS X, Windows, and Linux and on now on the desktop using “Apollo”.

Developers can use the Flex SDK to freely develop and deploy Flex applications using either Adobe Flex Builder or an IDE of their choice.

License

The source code for the Flex SDK will be available under the Mozilla Public License (MPL). The MPL will allow full and free access to the source code, allowing developers to download, extend, and contribute to the source code for the Flex compiler and framework classes. The Flex SDK will also be available under a commercial Adobe license. Offering a choice of licenses serves the needs of enterprise Flex customers and partners.

Mozilla Public License FAQ: http://www.mozilla.org/MPL/mpl-faq.html

The annotated Mozilla Public License (explained in layman’s terms) http://www.mozilla.org/MPL/MPL-1.1-annotated.html

Schedule

The source code for the Flex framework is already available within the free distribution of the current Flex 2 SDK. By this summer, Adobe plans to put in place most of the infrastructure (public bug database and public daily builds) required to run the Flex SDK as an open source project. We expect to complete the transition to a fully open source project (source code for the compiler, infrastructure for community contributions, etc.) by early 2008.

Currently Supported Platforms

  • Windows XP, Server 2003, or Windows Vista Professional/Ultimate with Java 1.4 (Sun, IBM, or BEA) or 1.5 (Sun)
  • Mac OS X 10.4.x, Java 1.5 (as shipped from Apple) on PowerPC and Intel processor
  • Redhat Enterprise Linux 3 or 4, Suse 10, Java 1.4 (Sun, IBM, or BEA) or 1.5 (Sun)
  • Solaris 9, 10, Java 1.4 or 1.5 (Sun) Compilers only

More Information and FAQ

This FAQ will provide all the details and hopefully answer all your questions.

How can I ask more questions?

You can participate in our discussion group.