|
|
Iam binding the list view thro this code..
When i click the list the values appears in textbox ..How can i take the values
Public Sub bindlist()
Try
Dim olecon As New OleDb.OleDbConnection
Dim olecomd As New OleDb.OleDbCommand
Dim dtst As New DataSet
' Dim emp As New ListBox
Dim strsql As String
Dim adpt As OleDbDataAdapter
strsql = ("User ID=sa;password=nimda;Data Source=CANARY\SOCPOS;Tag with column collation when possible=False;Initial Catalog=pay;Use Procedure for Prepare=1;Auto Translate=True;Persist Security Info=False;Provider=SQLOLEDB.1;Workstation ID=CANARY;Use Encryption for Data=False;Packet Size=4096")
olecon.ConnectionString = strsql
olecon.Open()
olecomd.CommandText = "select * from ps_bank"
olecomd.Connection = olecon
adpt = New OleDb.OleDbDataAdapter(olecomd)
adpt.Fill(dtst)
Dim bind As New Binding
bind.Source = dtst.Tables(0)
ListColor.DataContext = dtst.Tables(0)
ListColor.SetBinding(ListView.ItemsSourceProperty, bind)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
XAML:::
<Grid>
<TextBox BorderThickness="0" Text="{Binding Path=psc_code}"></TextBox>
</Grid>
</DataTemplate>-->
<DataTemplate x:Key="cellTemplateName">
<Grid>
<TextBox Name="txtname" BorderThickness="0" Text="{Binding Path=psbk_bankname}" VerticalAlignment="Center" ></TextBox>
</Grid>
</DataTemplate>
<DataTemplate x:Key="cellTemplateRGB">
<Grid>
<TextBox Name="txtrgb" BorderThickness="0" Text="{Binding Path=psbk_address1}"></TextBox>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="500" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ListView Name="ListColor" Grid.Row="0" >
<ListView.View>
<GridView AllowsColumnReorder="true" ColumnHeaderToolTip="Color Information" >
<!-- <GridViewColumn CellTemplate="{StaticResource cellTemplateCode}" Header="Code" Width="100"/>-->
<GridViewColumn DisplayMemberBinding="{Binding Path=psbk_bankcode}" Header="Code" Width="100"/>
<GridViewColumn CellTemplate="{StaticResource cellTemplateName}" Header="Name" Width="100"/>
<GridViewColumn CellTemplate="{StaticResource cellTemplateRGB}" Header="Address" Width="100"/>
</GridView>
</ListView.View>
</ListView>
<StackPanel Margin="0,20,0,0" Background="White" HorizontalAlignment="Left" Grid.Row="1" >
<Button Name="btnsave" Width ="50" Height="30" >Save</Button>
</StackPanel >
</Grid>
|
|
|
|
|
Create a new WPF Application solution and paste the code into it.
Run the application in debug mode.
Edit the grid.
Press the button.
Look in the Visual Studio output window and you'll see your new edited data.
I'm using a class instead of a data row, but the concepts are still the same.
You can look at the data context in the button's click event and see how to find the data.
In you case, Me.ListColor.Items will be a collection of DataRows. Just access the cells in the DataRow
Karl
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="400">
<Window.Resources>
<DataTemplate x:Key="cellTemplateName">
<TextBox BorderThickness="0" Text="{Binding Path=BankName}" />
</DataTemplate>
<DataTemplate x:Key="cellTemplateAddress">
<TextBox BorderThickness="0" Text="{Binding Path=BankAddress}" />
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView Name="ListColor" Grid.Row="0" ItemsSource="{Binding}" >
<ListView.View>
<GridView AllowsColumnReorder="true" >
<GridViewColumn DisplayMemberBinding="{Binding Path=BankCode}" Header="Code" Width="100"/>
<GridViewColumn CellTemplate="{StaticResource cellTemplateName}" Header="Name" Width="100"/>
<GridViewColumn CellTemplate="{StaticResource cellTemplateAddress}" Header="Address" Width="100"/>
</GridView>
</ListView.View>
</ListView>
<Button Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btnsave_Click" Margin="0,20,0,0" Content="Save" />
</Grid>
</Window>
Class Window1
Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
Dim obj As New System.Collections.ObjectModel.ObservableCollection(Of CodeNameAddress)
obj.Add(New CodeNameAddress("hello address 1", "name 1", "5"))
obj.Add(New CodeNameAddress("hello address 2", "name 2", "25"))
obj.Add(New CodeNameAddress("hello address 3", "name 3", "95"))
Me.ListColor.DataContext = obj
End Sub
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
For Each obj As CodeNameAddress In Me.ListColor.Items
Debug.WriteLine(obj.BankCode & " " & obj.BankName & " " & obj.BankAddress)
Next
End Sub
End Class
Public Class CodeNameAddress
Private _strBankAddress As String
Private _strBankName As String
Private _strBankCode As String
Public Property BankAddress() As String
Get
Return _strBankAddress
End Get
Set(ByVal Value As String)
_strBankAddress = value
End Set
End Property
Public Property BankName() As String
Get
Return _strBankName
End Get
Set(ByVal Value As String)
_strBankName = value
End Set
End Property
Public Property BankCode() As String
Get
Return _strBankCode
End Get
Set(ByVal Value As String)
_strBankCode = value
End Set
End Property
Public Sub New(ByVal strBankAddress As String, ByVal strBankName As String, ByVal strBankCode As String)
_strBankAddress = strBankAddress
_strBankName = strBankName
_strBankCode = strBankCode
End Sub
End Class
Cheers, Karl
» CodeProject 2008 MVP
» Microsoft MVP - Client App Dev
My Blog | Mole's Home Page | MVP Profile
Just a grain of sand on the worlds beaches.
<div class="ForumMod">modified on Friday, May 16, 2008 7:43 AM</div>
-- modified 27-Feb-21 21:01pm.
|
|
|
|
|
|
I forgot to mention, NICE Work with the Editable Grid.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hello Karl, if your info is up-to-date, and your employer is empgovpower you might be the best person to answer my q's...
Our company, creates software for law enforcement agencies... one of our major clients, has a deployment where its web based with ASP.... and an oracle back... .. .. you can imagine the nightmare...
our system pretty much gets rid of the "paper" based processes and docs and makes them electronic.
so the review-approve process exists,... a lot of the fancy stuff you can do with applications., doesnt apply to law enforcement agencies as the purpose is pretty specific., however., UI exp can be ofcourse improved.. which is why i have this question for you...
you are actively moving old apps into WPF., i WAS going to redesign the asp web app into a Web service + winforms app., since most local/state agencies have a disconnect with their IT., its easier to give the client an updated thinapp/winform, than have it deployed to the web farms.. i do plan on eventually creating a web based portal... but for now., i have a couple of weeks in which i need to create an application that displays the data that has been colllected + entered., request changes., approve changes., supplement reports., and so on.... as you can see., the greater concern is making sure data is good., and things are entered correctly since many of the documetns are legal documents...
So the main issue is i have no time., ive been with .net since its alpha stages., and i know my stuff., i dont know if i have time to play with wpf and make mistakes...
what do you think i should do?
Wpf now? or winform now, WPF later....
|
|
|
|
|
If you design the architecture correctly then neither should matter, you can use what you're most familiar with at the moment to get the first edition out of the door. Once you've got somre spare time and read up on WPF then you can move the code-base across to WPF as opposed to Windows Forms.
The problem with WPF that I see is that if you're a programmer then in all likely hood you'll want to employ a designer and/or get some professional components to make your life easier and look better.
For a good example of what I meant in the above paragraph take a look at Josh Smith's Podder application where he gives an example of a UI designed by a programmer and a UI designed by, well, a designer. Do you think you're capable of the second option?
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
thanks for your quick reply
1996 - 1999 and creeping into 2001 i was a graphic / flash person... then i jumped into the programming world., i am a jack of all trades., i can do both., and have been... the main meat of my product is a .net CF app that collects data., ditching the boring winform look, i used opennetcf to create a pretty application...
while wpf looks really good, and it might make it easier for me to close the deal on the product when shown., i might have to go with winforms so that the product is complete...
p.s. thank you for the ref to podder
|
|
|
|
|
Not a problem, not really coming from a design background (I can manage websites etc but then I have lots to base my designs on) then I see that flaw in WPF. In Windows.Forms it's easier for a non-designer like myself to make professional looking applications whereas the defaults in WPF tend to be quite bad.
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
|
Yep seen that one. Personally I feel that ok you can create an outlook clone but isn't the whole point of WPF to simplify things by creating a new UX (user experience)?
While I acknowledge the fact that there have been very vocal opinions against the ribbon in Office I feel that it is a positive step in the right direction. I'll always remember one of the girls on my corridor who I helped with some Excel work for a project, she was using 2003 and I 2007 and she immediately commented on how simple 2007 was to use (not having used Excel that much before). Having the things organised into the task-based tabs makes things quite a bit easier to find if you don't know what you're looking for.
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
i dont think its the ribbon effect that i am after., i just wanted to place the buttons in an easy to get to place., i cant rememer what its called but MS has a free small business accounting software that uses a similar design.,
I have looked at karls little app demo., and notice that all the open windows get added to the tab... i dont know if thats what i want to do... or should do for my app
I have a main dashboard, that shows statistics for the individual., total reports written., type of reports written so on... and there are 4 other specific report types., for example., Company A., hires runners/field agents, who go out., do meter readings., electric, water., gas so on.. collect data on a handheld,. and when they get back., sync the data., then on the WPF app., or winforms app., the login get the dashboard., and can then select
WATER
ELECTRIC
GAS
SEWAGE... the screen is actually broken up into 2 columns., the left navi bar and the content pane., so when you click water., it loads the water control.. which right now is actually a control that consists of a listview, search buttons, a "summary" pane...., you click on a report thats in the list,. it refreshes the summary pane with preview data (couple of fields + labels), double clicking opens up a new form window that displays the entire report... you can then edit it (another form that has all the edit logic),. view/export to pdf... and so on...
i dont mind showing my application., its not open source (yet)... what i want to do., is contine building my winforms application., and then start building the WPF part of it., then coming here onto the code projected and sharing all the stuff i have learnt.. the controls created and all the fun stuff
so... if anyone who knows wpf (you? Karl?) wants to have a lookie... id be glad to share my executables... its a winforms app talking to a web service., which i will eventually convert to wpf + wcf., and see how i can host the wpf onto a web based app., cant remember the tech term form that wpf/e ? too late to try and remember.,
so if anyone is interested in helping, who has real life business app dev knowledge using wpf., let me know im open to suggestions.,
|
|
|
|
|
zorro911 wrote: wpf/e ?
Unfortunately it was renamed to Silverlight.
zorro911 wrote: so if anyone is interested in helping, who has real life business app dev knowledge using wpf
You might want to take a look at Paul Stovell's Trial Balance[^], it provides a nice way of producing a first-screen so to speak. There's been another demo from Microsoft which was pretty cool but I can't remember what it was, something to do with Customer Relations but used a 3-d kind of tree view.
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
Hi All,
Before the flames start that isn't a woefully useless subject line!!
Has anyone come up with or have any links, useful info on adding help to a WPF application? This article seems like a good start in terms of context sensitive help but I also want to add a fully fleshed out help.chm or something more WPFie:
http://blogs.msdn.com/mikehillberg/archive/2007/07/26/a-context-sensitive-help-provider-in-wpf.aspx[^]
I guess I need to find an open source 'help.chm' authoring tool (Anyone know of a good one?) for the more traditional help solution. I would love to have something more WPF 'skinnable' though really. I have also considered having an entire page in the application that hosts a website page in a frame but that doesn't help users that aren't on the internet ...
Thanks in advance.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
|
Oh Good Grief ... is Microsoft's Help Workshop THE worst pile of **** ever or what???? Its horrific!!!!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
I have Binded the listview. when i click the columns it changes to textbox.. How to retrieve the textbox values while editing the textbox in listview.??
I want to update the database when i click the Save button .
<DataTemplate x:Key="cellTemplateName">
<Grid >
<TextBox Name="txtname" BorderThickness="0" Text="{Binding Path=psc_name}" VerticalAlignment="Center" ></TextBox>
</Grid>
</DataTemplate>
<DataTemplate x:Key="cellTemplateRGB">
<Grid>
<TextBox Name="txtrgb" BorderThickness="0" Text="{Binding Path=psc_rgb}"></TextBox>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="500" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ListView Name="ListColor" Grid.Row="0" >
<ListView.View>
<GridView AllowsColumnReorder="true" ColumnHeaderToolTip="Color Information" >
<!-- <GridViewColumn CellTemplate="{StaticResource cellTemplateCode}" Header="Code" Width="100"/>-->
<GridViewColumn DisplayMemberBinding="{Binding Path=psc_code}" Header="Code" Width="100"/>
<GridViewColumn CellTemplate="{StaticResource cellTemplateName}" Header="Name" Width="100"/>
<GridViewColumn CellTemplate="{StaticResource cellTemplateRGB}" Header="RGB" Width="100"/>
</GridView>
</ListView.View>
</ListView>
<StackPanel Margin="0,20,0,0" Background="White" HorizontalAlignment="Left" Grid.Row="1" >
<Button Name="btnsave" Width ="50" Height="30" >Save</Button>
</StackPanel >
</Grid>
|
|
|
|
|
What type of DataSource are you binding to?
It it is an ObserableCollection or a List collection the values should be automatically bound from the textbox back to the datasource with no requirements on your part. Just look at the data source for the values.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I'm a rookie of silverlight and currently use on silverlight 2 beta.
I have a problem about XML.
How can I write the data into the XML?
I have to create the dynamic navigation that have the admin part for admin login to edit contents. My navigation contents are created from XML file (this XML file not embed into XAP file) and include the element such as MenuName, Url, role, etc.
Now, my navigation can already read the contents from XML, but I can't write the data return to XML for edit my navigation.
|
|
|
|
|
You may know that Silverlight is running on the user's browser. (like Javascript and unlike ASP.NET)
So, it doesn't have the permission to write anything on the File System except Isolated Storage. The important question that I need to ask you back is ~~ where did you store the XML? or where do you want to store that XML file?
If you want to write the data into XML that is located in Server, you will need to use WebService for that. You need to invoke the webservice from Silverlight. Pass the data to webservice. write those data into XML from webservice.
|
|
|
|
|
|
Hi
Iam working with the WPF Grid (developed by ComponentOne) on Visual Studio 2008. I have to come up with a report using the DataGrid, which gives the user flexibility to choose the columns. For this I would like to use the ListBox/ComboBox so thst the user can select his/her choice of columns which would be displayed in the Grid.
My questions are :
i) How do I use the ListBox/ComboBox along with the Grid? Plz. suggest any instruction manual available in the net ?
ii) How do I bind the data to the selected columns from the two boxes to be displayed in the Grid? I might also have two selections to be made i.e. data will be filtered twice?
Plz. help immediately
Arijit
|
|
|
|
|
Arjit,
Did you contact ComponentOne tech support?
From what I can gather, you want the columns selected in the ListBox to show up in the grid, correct?
I would handle the item selected event in the ListBox and in code add the column to the grid in code. You probably want to put a button or a checkbox in each item in the ListBox so to make it easier for the user to use your solution.
Sorry, but I don't have the ComponentOne grid.
I hope this helps.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Thanks Karl
You have analysed the problem correctly.
I have already contacted ComponentOne tech support.
Regards
Arijit
|
|
|
|
|
Hi Karl,
I have run the program , but it is giving 2 errors.
i)Could not create an instance of type'StaticExtension'
ii)Cannot find the type 'VisibilityToBoolConverter'
I am sending the relevant XAML code as well as the VisibilityToBoolConverter.vb code
<XAML>
<CheckBox IsChecked="{Binding Visibility ,
Converter={x:Static local:VisibilityToBoolConverter.Default},
Mode=TwoWay}"/>
<TextBlock Text="{Binding Caption}"/>
</XAML>
<VisibilityToBoolConverter.vb>
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows.Data
Imports System.Windows
Imports System.Globalization
Namespace NEW_WpfApplication_20_5_08
Public Class VisibilityToBoolConverter
Implements IValueConverter
Public Shared ReadOnly [Default] As New VisibilityToBoolConverter()
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert
If TypeOf value Is Visibility Then
Return CType(value, Visibility) = Visibility.Visible
Else
Return Binding.DoNothing
End If
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
If TypeOf value Is Boolean Then
Return If(CBool(value), Visibility.Visible, Visibility.Collapsed)
Else
Return Binding.DoNothing
End If
End Function
End Class
End Namespace
</VisibilityToBoolConverter.vb>
Could you please point out the error in my application ?
Regards
Arijit
|
|
|
|
|