|
How have you obtained this Dll?
Silverlight may not support this version of the Dll.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Hi
I installed "SAP Crystal Report version for Visual Studio" .
In my web project when i tried to use Crystal Report to generate reports , and it generated this dll..
have yout ever tried to use Crystal Report in your web project ??
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
In a textbox of my wpf application, I would like to only allow numbers i.e.:
21 or 19.50 or 12.75 or 10
Can you see how my code below can be corrected because it only allows numbers such as 21, 1950, 1275, 10, etc... ?
Thank you
private bool IsDecimal(string text)
{
bool blnValidDecimal = false;
foreach (char c in text)
{
if (Char.IsNumber(c))
{
blnValidDecimal = true;
}
if (char.IsDigit(c))
{
blnValidDecimal = true;
}
}
return blnValidDecimal;
}
private void txtAvgGrade_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !IsDecimal(e.Text);
}
|
|
|
|
|
You might find decimal.TryParse useful.
decimal d;
return decimal.TryParse(text, out d);
|
|
|
|
|
Rather than attempting to reinvent the wheel, why not make use of the Attached Behavior I wrote here[^]? It gives you a lot of flexibility in how you accept your numbers, and manages features such as disallowing/allowing negative numbers, the number of decimal places allowed, whether or not the textbox accepts decimals or not.
|
|
|
|
|
thanks but I would like to get this existing code working.
Any thoughts on that please?
Thanks
|
|
|
|
|
Take a look at how I validate the input in that code. That's what you need to do. With your code, you are missing things like coping with the user pasting crap in. As long as they don't press a key, you have left your validation wide open.
|
|
|
|
|
|
Bloody net nazi won't let me in there, just you wait till I get home to a decent connection I'm gonna vacuum up all those behaviours I can find. I am only just getting a handle on how useful these things are.
I have a tremendous dislike for rewriting code and these fit very nicely with that idea.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I am only just getting a handle on how useful these things are.
They really are useful. I love behaviors; so much so that we are supplying a lot of them to clients to cut down on the amount of boilerplate validation that needs to be performed.
|
|
|
|
|
In a textbox for the wpf application, how can I make sure the user enters a valid email address please?
I am using regular expressoion as follows but clicking away from the textbox still seems to be ok even if there is no proper email address in the textbox.
And I am not sure if regular expression is the right thing for this purpose.
Thanks
My existing code:
private static bool IsEmailAllowed(string text)
{
Regex regEMail = new Regex(@"^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
return !regEMail.IsMatch(text);
}
private void txtEmail_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !IsEmailAllowed(e.Text);
}
This is what I used to do in windows but there is nothing similar to it in wpf
private void txtEmail_Validating(object sender, CancelEventArgs e)
{
System.Text.RegularExpressions.Regex rEMail = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
if (txtEmail.Text.Length > 0)
{
if (!rEMail.IsMatch(txtEmail.Text))
{
MessageBox.Show("E-Mail expected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtEmail.SelectAll();
e.Cancel = true;
}
}
}
|
|
|
|
|
If only somebody had written an attached behaviour to allow the user to prevent invalid values being typed in (or pasted in). Why, I think somebody might just have done that - wait, let me check.
By golly, it was me. You can find details here[^].
|
|
|
|
|
Thank you for the link...
However, I am trying to use the following method instead which is due to the requirements...
The problem is that I would like to call the IsEmailAllowed when I click away from the Email textbox.
As you see now, the call is in the txtEmail_PreviewTextInput and so, it returns false for each character I enter into the textbox.
Which event of the textbox can I place the code e.Handled = !IsEmailAllowed(e.Text); so it gets called after clicking away from the textbox.
Thanks
private static bool IsEmailAllowed(string text)
{
bool blnVallidEmail = false;
Regex regEMail = new Regex(@"^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
if (text.Length > 0)
{
if (!regEMail.IsMatch(text))
{
MessageBox.Show("E-Mail expected", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
blnVallidEmail = !regEMail.IsMatch(text);
}
}
return blnVallidEmail;
}
private void txtEmail_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !IsEmailAllowed(e.Text);
}
|
|
|
|
|
You can try putting the call into the TextBox's LostFocus event, which fires when the TextBox loses focus(funny that).
Hope this helps
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
|
arkiboys wrote: However, I am trying to use the following method instead which is due to the
requirements...
What requirements do you have that say you have to provide your own preview check input? What you are trying to do here is actually poor form - if the user types in that doesn't match the regular expression you throw a message box up - it's better to prevent them from putting in an invalid value than telling them they got it wrong. BTW, you are using the preview key event here and then extracting the value from the textbox. In other words, if the user types in all valid characters bar the last one, your code won't catch it because it is reacting to the values that are already in the textbox, which does not include the key you've just pressed.
If what you are trying to do is just validate the input, then you need to implement IDataErrorInfo on your ViewModel, and then add the following to your binding in the textbox:
UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=true, NotifyOnValidationError=true By handling LostFocus, the validation will only occur when you focus away from the textbox. To add the validation in, you need to add the following code:
public string Error
{
get { throw new NotImplementedException(); }
}
public string this[string columnName]
{
get
{
string result = null;
if (columnName == "Email")
{
Regex regEMail = new Regex(@"^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
bool isValid = regEmail.IsMatch(Email);
if (!isValid)
{
result="You must enter an email";
}
}
return result;
}
}
|
|
|
|
|
|
|
Hi,
I got that how to bind the data to a control, my question is how to read the specific data from that listbox.itemtemplate and pass it as a request...
this is my xaml file..
<ListBox Grid.Row="1" Grid.Column="2" x:Name="lbDirectiveList" ItemsSource="{Binding}" SelectionChanged="lbDirectiveList_SelectionChanged" MaxHeight="200" SelectionMode="Single" ScrollViewer.VerticalScrollBarVisibility="Auto">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="25" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Path=DirectiveName, Mode=TwoWay}" Grid.Column="0" FontWeight="Bold" MinWidth="200"/>
<TextBlock Text=" - " Grid.Column="1"/>
<TextBlock Grid.Column="2" Text="{Binding Path=DirectiveDescription, Mode=TwoWay}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
here the directive name and description is displayed in a listbox, i have to get the directive name which is present inside the listbox and pass it in a soaprequest, so could u help me how to do it..
any idea...
|
|
|
|
|
You should not be reading data from the itemtemplate.
You should be reading data from the itemssource / datacontext source collection that you have bound to your listbox.
That should be fairly easy to pass to the service.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
so can u tell me how can i get the data through itemsource, i have to get all the DirectiveName data from listbox.
ObservableCollection<DADirective> listdata;
DADirective SelectDirective;
public void LoadDirective()
{
listdata = new ObservableCollection<DADirective>();
SelectDirective = (DADirective)lbDirectiveList.SelectedItem;
listdata.Add(new DADirective { DirectiveName = "Filter trading account", DirectiveDescription = "Rows will Trading account value to be filtered" });
listdata.Add(new DADirective { DirectiveName = "Filter Counter party rows", DirectiveDescription = "Rows where counter party is null will be filtered" });
listdata.Add(new DADirective { DirectiveName = "Filter USD currency records", DirectiveDescription = "Filter those rows where currency is USD" });
lbDirectiveList.ItemsSource = listdata;
}
|
|
|
|
|
You don't need to do anything special to read the data out of the data context or anything. All you need to do is get the data out of listdata. That's what you've bound to, there's no magic going on under the hood, so you could use a simple foreach and iterate over the listdata collection.
|
|
|
|
|
Hi please recommend any third party api for Line Chart. which has the feature of Zooming and panning and should be allowed 200,000 points.
Please let me know
|
|
|
|
|
I dont know if the charting toolkit provided on codeplex can help you - its open source.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|