1 Replies - 4572 Views - Last Post: 16 November 2012 - 09:19 AM Rate Topic: -----

#1 Kitchu177   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-March 09

wpf datagrid datatemplatecolumn

Posted 16 November 2012 - 02:46 AM

I'm using wpf datagrid for editing sales entries like quantitiy,discount etc. I'm using DataTemplateColumn for each editable columns and texbox control inside each column. Each textboxes are binded to different columns of DataTable. While editing quantity, i have to calculate the net amount and update that column (done by updating the datatable which was bounded to grid). Handling everything inside text changed, lostfocus, gotfocus etc of each editable textboxes. The datagrid selection unit is set to "Cell".

Now the problem is lots of issues are coming while using this method. Sometimes textchanged event of textboxes inside templatecolumn are firing multiple times which makes all calculations wrong.

Can anybody tell what is the best method to edit grid using datatemplate column? I have to use textboxes itself because we have a number pad control which supports only textboxes. Why textchanged events are firing multiple times? This happens even when we scroll the grid vertically.

Is This A Good Question/Topic? 0
  • +

Replies To: wpf datagrid datatemplatecolumn

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6534
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: wpf datagrid datatemplatecolumn

Posted 16 November 2012 - 09:19 AM

.TextChanged happens every time the text is changed - That's its job. So if you type "fred" then .TextChanged happens 4 times because each character is a change.

If you are working off these events then you're using a WPF window like you would an older WinForm form.

It would be better to bind the GUI control to a property in the code behind. That way the property only changes when the user is done editing on the Window and move to the next control.

There is an example of this in the Properties tutorial linked in my signature block.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1