.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

UpdateSourceTrigger="LostFocus" of a RichTextBox in a DataGridTemplateColumn is not raised ?

Posted By:      Posted Date: September 26, 2010    Points: 0   Category :WPF


for me this seems like a BUG.

You can download a sample project VS 2010 here: http://www.sendspace.com/file/xtn1mc

Bug scenario:

- When you click from the left Content Cell to the right Homework cell staying on the SAME ROW => LostFocus does not work!

- When you click from the left Content Cell to the right Homework cell of ANOTHER ROW => LostFocus works!

- Clicking on all 4 cells from the Content immediately raises a property changed event.

And now the CRAZY stuff...:

- Clicking on all 4 cells from the Homework column starting for example at the first cell entering "test" clicking in 2nd cell entering "test" clicking in 3rd cell entering "test" clicking in 4th cell entering "test" NOTHING happend.

When I go now the same way in reverse order from cell 4 to cell 1 sometimes I get property changes ROFL ...

Can you explain that? 

- The Content Column is a DataGridTextColumnT

- The Homework Column is a DataGridTemplateColumn with your DataTemplated RichTextBox.

The RichTextBox I use is from the Extended W

View Complete Post

More Related Resource Links

Event not raised while parsing xml file



In Visual Studio 2010 ASP.NET 4.0

I want to write a procedure to validate a xml file with a xsd. I found some examples on the web but the one i chose does not work as attended. The example uses XmlReader with a XmlReaderSettings and a ValidationEventHandler.

Here is the code

Protected Sub VerifyDes(ByVal filename As String)

        Dim xslDes As XmlReaderSettings = New XmlReaderSettings()
        xslDes.Schemas.Add("", "http://www.mysite.com/xsd/ValidData.xml")
        xslDes.ValidationType = ValidationType.Schema
        xslDes.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings

        AddHandler xslDes.ValidationEventHandler, AddressOf xslDesValidationEventHandler

        Dim des As XmlReader = XmlReader.Create(filename, xslDes)

        While (des.Read())

        End While

    End Sub

    Protected Sub xslDesValidationEventHandler(ByVal sender As Object, ByVal e As ValidationEventArgs)

        'some code here
    End Sub

I tested this procedure with a xml file which was well formed but contained some elements which were not conform to the xsd.

No event or error occured. It said the file was valid.

Then i tested with a badly formed file. A XmlException was raised but nothing happened with the ValidationEventHandler.

It seems lik

For a control which events are raised at design-time, run-time or both?

Hi. I have been getting several different errors on the my windows forms designer. I'm trying to implement an application with some complexity on the screen navigating since it includes several main views as also sub-views in which the sub-views are represented by user controls. I believe that some of my errors are related to the fact that I miss important information related the events that are raised while working in the windows forms designer. Is there any link that includes information about the events of a control that are raised at design-time, run-time or both? For example, if I override the OnLoad() method of a User Control, that method will be executed both at design-time and run-time. Knowing about this information has helped me resolving an issue related to duplication of columns on a customized DataGridView. Not 100% sure if it's possible to obtain what I'm asking for or if this information exists. If this information is not available what could I do in order to understand in more detail the kind of events that are raised in the design-time vs run-time? Can I debug an application in design-time using Visual C# 2008 Express Edition? I found this link that helps identifying the run-time and the design mode: http://dotnetfacts.blogspot.com/2009/01/identifying-run-time-and-design-mode.html This link has been helpful but I still feel that I need more information.

Printing RichtextBox

I was using the following code to print the contents of a richtextbox:         pd.PrintDocument(((CType(Me.richTextBox.Document, IDocumentPaginatorSource)).DocumentPaginator), "printing as paginator")but it prints in 3 columns. So i tried using this code but it does not print InluneUiContainersDim docWriter As XpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(ia)     If (docWriter IsNot Nothing And ia IsNot Nothing) Then         Dim paginator As DocumentPaginator = CType(fd, IDocumentPaginatorSource).DocumentPaginator         'Change the PageSize and PagePadding for the document to match the CanvasSize for the printer device.         paginator.PageSize = New Size(ia.MediaSizeWidth, ia.MediaSizeHeight)         Dim pagePadding As Thickness = fd.PagePadding         fd.PagePadding = New Thickness    (Math.Max    (ia.OriginWidth,     pagePadding.Left),     Math.Max    (ia.OriginHeight,     pagePadding.Top),         Math.Max(ia.MediaSizeWidth - (ia.OriginWidth + ia.ExtentWidth), pagePadding.Right), Math.Max(ia.MediaSizeHeight - (ia.OriginHeight + ia.ExtentHeight), pagePadding.Bottom))     fd.ColumnWidth = Double.PositiveInfinity     'Send DocumentPaginator to the printer.     docWriter.Write(paginator) End If Also tried the following but this is completely wrong:        pd.PrintVisual(CType(Me.richTextBox, Visual), "printing as visual")Any ideas?

RichTextBox - Attached Properties, Document and CaretPosition

Hi I have created a couple of attached properties for the richtextbox control, to enable binding to the Document and CaretPosition native properties of the richtextbox. However, I am finding that, when I am programmatically updating the richtextbox document from the view model (rather than typing it into the richtextbox directly), I need to manually set the CaretPosition property of the richtextbox (see the underlined piece of code for the additional manual setting of CaretPosition) whereas the Document property appears to be updating automatically. At least when I step the code and break in on I'm concerned that I've not quite wired this together properly and would be grateful if someone could explain where I've got it wrong. The relevant  XAML is  <RichTextBox x:Name="rtb" Height="auto" Width="auto" local:RichTextBoxExtensions.CaretPosition="{Binding CaretPosition, Mode=TwoWay}" local:RichTextBoxExtensions.CurrentText="{Binding CurrentText, Mode=TwoWay}" cal:Message.Attach="[Event TextChanged] = [Action CheckForPopup]; [Event PreviewKeyUp] = [Action KeyPress($eventArgs)]"> <local:RichTextBoxExtensions.Document> <MultiBinding Converter="{StaticResource IntellisenseController}"> <Binding Path="CurrentDocument" Mode=&qu

Full desired height of a RichTextBox control?

I don't mean the control's .Height property... ...I have a WinForm with a RichTextBox control, and another control underneath the RichTextBox control.  The RichTextBox control is anchored on the left, top, and right sides, so the width is automatically resized as the parent form is resized.  (it also has its Multiline and and WordWrap properties set to True) The item underneath the RichTextBox needs to always be right underneath it (little whitespace), and the RichTextBox needs to always display its entire text (nothing hidden). As I get the form's resize event, I'd like to update the RichTextBox's hight so all text is displayed, however I'm not seeing any properities or methods which would be helpful.  There is the PrefferredHeight property, but it is always returning 13. Basically, it comes dowen to this: when WordWrap is set to true, is there a way to see what the desired height is?  Or is there a way to see if any of the text is clipped? If not, I suppose my next step would be to roll my own custom control and draw the text myself, keeping track of the autowrap and line count, but I thought I'd post a message here first and see if anyone has a better idea. Thanks, Jeff      

double spin text in richtextbox

i want to implement this feature : if i have a following sentence : {my name is james vick and iam a {member|user|visitor} on this {forum|website|site} and iam loving it | iam admin and iam a {supervisor|admin|moderator} on this {forum|website|site} and iam loving it} on a click of button i want to generate this : my name is james vick and iam a member on this site and iam loving it or iam admin and iam a admin on this forum and iam loving it The basic need is to randomly choose words between {|} braces I have been able to do this for inner nest i.e. for {member|user|visitor}. But how to include the outer nest of sentences also i.e. {something blah blah {blah1|blah2} and | something else} ? code for inner nest : Private Sub SimpleButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton3.Click Dim stringWithTextIn As String = RichTextBox1.Text Dim regex As New Regex("{(.*?)}") Dim r As String = regex.Replace(stringWithTextIn, New MatchEvaluator(AddressOf ReplaceMatch)) RichTextBox2.Text = r End Sub Private Function ReplaceMatch(ByVal m As Match) As String Dim parts = m.Groups(1).Value.Split("|"c) Return parts(r.Next(0, parts.Length)) End Function i know i just have to change the regex but what do i add in it to include outer braces?

Exception not raised on instead of trigger

I am checking some data prior to insert using an instead of trigger.  The trigger checks to see if a person being inserted has specific status ( bool(bit) isStaffManager=1) in the Person table.  If bit = 0 an exception should be thrown.  For some reason the trigger seems to try to insert before raising my exception and throws a null exception when @Manager is unassigned.  If I assign a value, even an invalid one, to the variable it works OK.  I don't understand why. From the code below if I remove the line "Set @Manager = ''; (marked near the end of the trigger code) I get the error "can't insert null into manager..." If I put the line in it works OK- Raises my exception with message - "Manager Required...".  Why is the trigger attempting an insert instead of throwing the exception?  And why does the line this assignment fix this? TIA CREATE TABLE [dbo].[Job](  [Job] [varchar](64) NOT NULL,  [Description] [varchar](max) NOT NULL,  [Manager] [varchar](64) NOT NULL,  [ProjectCode] [varchar](6) NOT NULL Default 0,  [ExecptionSourceTitle] [varchar](64) NOT NULL Default '',  CONSTRAINT [PK_Project] PRIMARY KEY CLUSTERED (  [Job] ASC ) ) ON [PRIMARY] CREATE TABLE [dbo].[Person](  [Person] [varchar](64) NOT NULL,  [HireType] [c

missing event in RichTextBox

I'm developing an application that uses the RichTextBox extensively, I need an event that gets triggered at the moment when the vertical scroll bar of the richTectBox appears . so instead of scrolling down to see the rest of the text I want to create another RichTextBox that will hold the rest of the text which didn't fit in the first one …I want to achieve the same functionality as in MS word. I tried so hard to achieve that functionality but it wasn't successfull … I tried to fake it using the SizeChanged event but it wasn't practical because the size of the richTextBox gets changed a lot during the life time of the application   is there such event in windows forms ? … and if not , is there one in WPF ?

Problem when Append DataFormats.xamlPackage RichTextBox

public partial class Window12 : Window { public Window12() { InitializeComponent(); } FileStream fStream; private void btnClick_Click(object sender, RoutedEventArgs e) { TextRange ran = new TextRange(txtMsg.Document.ContentStart, txtMsg.Document.ContentEnd); ran.Save(fStream, DataFormats.XamlPackage); txtMsg.Document.Blocks.Clear(); txtMsg.Focus(); } private void Window_Loaded(object sender, RoutedEventArgs e) { string fileName = @"D:\\part1.xaml"; if (File.Exists(fileName)) fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write); else fStream = new FileStream(fileName, FileMode.Create); txtMsg.Focus(); } private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { fStream.Close(); } } Hi, I have WPF RichTextbox and a button When I insert the text or Image and Click the button the text will save in D: drive with DataFormats.XamlPackage Initially it works fine, when I try to append the text (Close window and open again then insert the text )It gives the error in range.Save(fStream,DataFormats.XamlPackage); Error Message:Cannot open package because FileMode or FileAccess value is not valid for the stream.am

Possibly Severe Bug in Windows Forms / TextBox / RichTextBox, Windows Freezing

Problem: Windows Message Processing (in all running apps) completely freezing periodically for about 10 seconds when using certain combination of Forms properties on a form with a TextBox/RichTextBox. This behaviour might not be limited to the two controls. The weird behaviour starts with but is not limited to scrolling text in the textbox with the mousewheel. Using: Visual Studio 2008, Visual Basic, compiling for .NET Framework 3.5 (Any) OS: Windows XP SP3 Reproduce: Open new project, add a new form named TestForm, add a TextBox named TextBox1, enable scrollbars on the TextBox. Add the following function to the form: Public Class TestForm     Private Sub TestForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load         ' CONDITIONS WHEN STARTS TO SLOW DOWN:         ' Form.Opacity < 1.0         ' Form.BackColor = Form.TransparencyKey (= whole form is transparent)         ' this makes the form completely transparent         BackColor = Color.Red         TransparencyKey = Color.Red         ' NOTE: when this is set it starts to slow down         Opac

databinding combobox which is inside a datagridtemplatecolumn

My datagrid is bound to a datacontext and I have a combobox inside a template column which has to be bound to a data source out of the existing datacontext.  I couldnt access that combobox from code behind. How can I achieve this. Also may i have a good learning resources for styling datagrid. Thanks :)   EDIT: I have two datatables in a dataset and my need is to intermix the data from both. Initially i set the data context to dataset.table1. Now I wanted to get values from other. So I tried the code-behind and found that I cant access elements in the datatemplate.   EDIT 2: I tried something like this: From code-behind: set Me.DataContext=mydataset And in XAML: when I wanted the values from 1st datatable: set the binding to table1/field. But I could see oly the first row of the datatable. 

How can I hide the caret of a RichTextBox control?

Hello,Can you please tell me how can I hide the caret of a RichTextBox control completely while my app is running?Thanks.

Richtextbox - how can I find out what lines are currently visible?

I have a scrolling richtextbox that holds more lines than it can display, and I would like to know what lines are currently being displayed.  I'm looking for some method like GetTopVisibleLine, GetBottomVisibleLine, GetFirstVisibleCharIndex, GetLastVisibleCharIndex, etc. and I don't seem to be able to find anything that will give me this info.  Any ideas? Thanks, Mike

use icons for richtextbox

(using vb.net 2008).  I am using the richtextbox (WinForms, not WPF) to stream messages to the user.  I'd like to insert symbols with the messages, particularly the red exclamation point of ErrorProvider for warning messages (I'm not saying I need errorProvider itself, just like to use its symbol).  The symbols should position and size themselves appropriately depending upon the richtextbox font or style. I guess question 1 is, am I really on the right track using the WinForm richtextbox for this purpose, or is this functionality too difficult?  If not, how would I insert the errorprovider's exclamation point icon into the RTF?  

When exactly does UIElement.LostFocus fire?

I am observing that if a control is deep within the Visual tree of a user control, and I click on another element further up or down the tree, UIElement.LostFocus does not fire.  If, however, I click on a closer element or its immediate parent, LostFocus fires correctly.  Am I missing something?

Click.CommandParameter null when binding on Button inside DataGrid DataGridTemplateColumn

I am having trouble getting a Click.CommandParameter to pass through with a bound Click.Command. I have a DataGrid with a DataGridTemplateColumn that contains a couple of Buttons. Using a suggestion found on the forum (http://social.msdn.microsoft.com/Forums/en/wpf/thread/541024a9-3d7e-4c6a-b88e-9a7eb7ee83a9), I was able to get the Click.Command to bind to the right command, but when arriving in the corresponding method in my ViewModel, the parameter is null.  Here is my xaml for my DataGridTemplateColumn <data:DataGridTemplateColumn Header="Case">  <data:DataGridTemplateColumn.CellTemplate>   <DataTemplate >    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">     <Button Content="Open" Margin="6,0" command:Click.Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type data:DataGrid}}, Path=DataContext.OpenCaseCommand}" CommandParameter="{Binding}"  />     <Path Data="M1,1 L1,2" Stroke="#FFCCCCCC"/>     <Button Content="Rename" />    </StackPanel>   </DataTemplate>  </data:DataGridTemplateColumn.CellTemplate> </data:DataGridTemplateColumn> I used Snoop to see what was going on. Everything
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend