|
|
Hi All
i am converting an Excell spreadsheet into an application. So i am doing automatic calculations like Excell do , for some of the cells(textbox) should allow a user to enter the minus sign "-" , and this automatically minus value entered. So my issue here is if th the users enters that character it breaks my app's calculations. Does anyone have any idea how to bypass this ?
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
Vuyiswa Maseko wrote: So my issue here is if th the users enters that character it breaks my app's
calculations. Does anyone have any idea how to bypass this ?
Without knowing how your application works, no. I don't know what code you've actually written, so how can I tell you what's wrong with it. I will say one thing though - if you can cope with positive numbers, you should be able to cope with negative ones. After all, taking away is merely adding a negative number.
|
|
|
|
|
hi Pete
Thanks for your reply. i am just looking at ideas without any coding examples. What i need is a logic to bypass this.
lets take a Cell in an Excel spreadsheet,you normally can enter numeric values and by default anything that has no sign "-" is a "+" so now when it comes to negative in Excel it will subtract the value in the cell from somewhere. So in .e.g asp.net or silverlight , if you want to mimic that Excel behavior how can do that , because immediately when that value is entered it changes the data in the textbox not to fall under "int" or "decima" because there is a special character.
You know what ?
i just Figured out.
i will keep the value as is and when it is being calculated against another Field , i will sum what needs to be summed and subtract on any field that has that sign
Sometimes when you explain the problem to someone you might find the solutiion
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
Vuyiswa Maseko wrote: Sometimes when you explain the problem to someone you might find the
solutiion
Often the way my friend, and a 5 for such enlightenment.
|
|
|
|
|
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
|
Thanks nice
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
How to Comments on image at dynamically write sometext
on image in Silverlight.
|
|
|
|
|
If you just want to display dynamic text over the top of an image that is displayed in the UI, you simply need to place a TextBlock on top of the image and set the Text as appropriate.
|
|
|
|
|
<Grid>
<Image source=""/>
<TextBox Text="Enter comments here.." VerticalAlignment="Center"/>
</Grid>
The above code will put a TextBox in the center of the image where you can enter your comments. Further if you want to have an image with commented text that also you can create a dynamic Bitmap image.
Cheers!
Vinod
http://www.exploresilverlight.com
Cheers!
Vinod
|
|
|
|
|
How To create Image Annotation in Silverlight,Please
Help me.
|
|
|
|
|
Can someone atleast help me to find the mouse pointer location over the webbrowser control in WPF.
The only constraint is that you cannot create an event of the webbrowser control.
And just for the records,
Point p = Mouse.GetPosition(webBrowser1);
is not working !
|
|
|
|
|
You can get the Mouse Pointer as bellow:
Point p = this.PointFromScreen(Mouse.GetPosition(this));
txtX.Text = p.X.ToString();
txtY.Text = p.Y.ToString();
|
|
|
|
|
It is convenient to have an "Accept Button" (in WPF: IsDefault="True" ) on a Form.
In the Windows Forms world, I used to read the data from the UI to the object(s) in the corresponding Click event of the button.
But with WPF, data binding ought to be used. In the constructor of the Window, I set this.DataContext = test;
And here comes the problem: the user entered some text in TextBox2 , and hits the Enter key. Now, the command bound to the OK button gets executed, the data are saved.
But it is not the correct data! Why? TextBox2 has not yet lost focus, and consequently the ViewModel has not yet been updated.
[Edit]In Windows Forms, several controls have a Validating event. That event gets fired before the Click event event of the button, though the focus remains on that element.[/Edit]
How do you overcome such a problem?
modified 5-Jul-12 6:01am.
|
|
|
|
|
You should set the TextBox's UpdateSourceTrigger property to PropertyChanged and then it will automatically update the ViewModel whenever any changes are done to the text. Something like this :-
Text="{Binding Path=yourTextProperty, UpdateSourceTrigger=PropertyChanged}"
By default this property is set to LostFocus, which only updates the property when the user moves focus to another control.
Hope this helps.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Thanks for the idea. But it is not only one text box. The user can hit the Enter key anywhere. And on every form with an accept button. This means that a general solution is required.
|
|
|
|
|
You can use UpdateSourceTrigger=”OnPropertyChanged” as a workaround to help you fix this in some scenarios.
Otherwise, its a WPF bug.
Check this post[^] out as well.
|
|
|
|
|
That link is very interesting. I have checked with a Windows Forms application (also .Net 4, Visual Studio 2010): the Leave event (corresponding to LostFocus) does not happen when the user hits the Enter key. That means, this behavior is consistent between Windows Forms and WPF. Only due to DataBinding, a problem arises.
[Edit]Test with C# 2005 Express, .Net 2: same behavior[/Edit]
modified 5-Jul-12 5:45am.
|
|
|
|
|
A while back, I created an Attached Behavior (I'm well known for my love of them), which I attach to the default button. This behaviour hooks into the click event and calls the following (this is from memory, so I apologise in advance if it's not 100% correct)
private void UpdateFocussed()
{
FrameworkElement el = Keyboard.FocusedElement as FrameworkElement;
if (el != null)
{
BindingExpression expression = null;
if (el is TextBox)
{
expression = el.GetBindingExpression(TextBox.TextProperty);
if (expression != null)
{
expression.UpdateSource();
}
}
}
}
|
|
|
|
|
That is a nice workaround.
|
|
|
|
|
You are too clever, sir !+5
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
My 5! It works.
I tested then with ComboBoxes and CheckBoxes, and fortunately they do not need such an extra treatment.
|
|
|
|
|
I blogged about this here[^], and I've uploaded this to CodeStash[^] as well.
|
|
|
|
|
I'm trying to use a series of cascading controls to filter a datagridview.
I've built a local sdf database and set up the datatable I wish to use in my gridview.
I created a combobox which I bound to my datatable and happily populates my regions
This then populates a second control (checkboxlist) which returns a set of checbox selections for the region selecetd in the combobox (This also works fine).
Finally I have my datagridview and this is where I have an issue.
The Grid is populated via the same table and fills as you select from the combobox but only for recordsets with the 1st terminal selection.
What I so far seem unable to do is work out how to use the checkboxlist to filter the datagridview.
I've tried adding a datatemplate and then code behind to create an observable collection but then my checkboxlist stopped working.
I'd really appreciate any advice or help on how to solve this as I'm sure it is simpler than I'm making it.
This is my XAML currently with the datatemplate though it seems to populate the checkboxlist fine without that template:
<Window.Resources>
<my:VlogicaDataSet x:Key="vlogicaDataSet" />
<CollectionViewSource x:Key="_Regions_ViewSource" Source="{Binding Path=_Regions_, Source={StaticResource vlogicaDataSet}}" />
<CollectionViewSource x:Key="_Regions__Terminal_ViewSource" Source="{Binding Path=Regions$_Terminal$, Source={StaticResource _Regions_ViewSource}}" />
<CollectionViewSource x:Key="_Regions__Terminal_GridViewViewSource" Source="{Binding Path=Terminal$_GridView, Source={StaticResource _Regions__Terminal_ViewSource}}" />
</Window.Resources>
<Grid>
<GroupBox Header="Analysis Mode" Height="471" HorizontalAlignment="Left" Margin="12,185,0,0" Name="groupBox1" VerticalAlignment="Top" Width="1463" Foreground="Orange">
<Grid DataContext="{StaticResource _Regions__Terminal_GridViewViewSource}">
<TabControl Height="372" HorizontalAlignment="Left" Margin="14,18,0,0" Name="tabControl1" VerticalAlignment="Top" Width="235">
<TabItem Header="Forecasting" Name="tabItem1">
<Grid DataContext="{StaticResource _Regions_ViewSource}">
<Label Content="Region Selection" Height="28" HorizontalAlignment="Left" Margin="6,17,0,0" Name="label1" VerticalAlignment="Top" FontWeight="Bold" />
<ComboBox DisplayMemberPath="GROUPNAME" Height="23" HorizontalAlignment="Left" ItemsSource="{Binding}" Margin="10,46,0,0" Name="_Regions_ComboBox" SelectedValuePath="GROUPNUM" VerticalAlignment="Top" Width="196">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<xctk:CheckListBox DataContext="{Binding UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Source={StaticResource _Regions__Terminal_ViewSource}}" Margin="10,102,20,77" Name="clbTerminals" SelectedItems="{Binding}" SelectedMemberPath="IsSelected" SelectedValue="{Binding Path=SelectedValue}" ValueMemberPath="Level" DisplayMemberPath="NAME">
<ItemsControl>
<DataTemplate>
<CheckBox IsChecked="{Binding Path=Selected}" Content="{Binding Path=Description}"/>
</DataTemplate>
</ItemsControl>
</xctk:CheckListBox>
And this was the code behind class for the observable collection:
public ObservableCollection<CheckedItem> List { get;set;}
public class CheckedItem
{
public bool Selected { get; set; }
public string Description { get; set; }
}
Though this currently returns a debug error on the Observablecollection which says expecting class delegate, enum, interface,structure.
This was code I found researching online for an answer and tried to adapt in my VS2010 project.
|
|
|
|