Click here to Skip to main content
15,913,685 members
Home / Discussions / C#
   

C#

 
GeneralControl collection Pin
magnifique4-Aug-05 1:44
magnifique4-Aug-05 1:44 
GeneralRe: Control collection Pin
Roger Stewart4-Aug-05 3:45
professionalRoger Stewart4-Aug-05 3:45 
GeneralRe: Control collection Pin
magnifique5-Aug-05 0:16
magnifique5-Aug-05 0:16 
Generali need to ask u some questions to get started in doing a database Pin
nidhelp4-Aug-05 0:52
nidhelp4-Aug-05 0:52 
GeneralRe: i need to ask u some questions to get started in doing a database Pin
magnifique4-Aug-05 1:42
magnifique4-Aug-05 1:42 
GeneralRe: i need to ask u some questions to get started in doing a database Pin
nidhelp4-Aug-05 14:52
nidhelp4-Aug-05 14:52 
GeneralLogging Window Pin
Verio6664-Aug-05 0:33
sussVerio6664-Aug-05 0:33 
QuestionHow to delete row in datagrid/datatable with a delete button Pin
Atlemann4-Aug-05 0:30
Atlemann4-Aug-05 0:30 
Hi!

I can't seem to make it work. I select a row in a datagrid and press a delete button. That row is then deleted. But if i add/delete many rows, then close and reopen my dialog and try to delete a row again, the row with index 0 is deleted instead of the one i have selected. I have tried to use currency manager to delete and everything, but I can't make it work properly.

This is how I delete a row:
<br />
if(_currencyManager.Current.GetType() != typeof(DataRowView)) return;<br />
				<br />
DataRowView dr = (DataRowView)_currencyManager.Current;			<br />
dr.Delete();   <br />
_currencyManager.EndCurrentEdit();<br />
_currencyManager.Refresh(); <br />
_dtPplan.AcceptChanges();<br />


I set the currency manager like this:
<br />
_currencyManager = (CurrencyManager)this.BindingContext[dgPplan.DataSource, dgPplan.DataMember];      


And fill the table with data like this each time i open the dialog. Just so i'm sure it got the latest data:
<br />
_dtPplan.Rows.Clear();<br />
foreach(PPlan pPlan in valueObject.PPlan) <br />
{				<br />
 DataRow dr = _dtPplan.NewRow();<br />
 dr[NetworkKeywords._cCriteria] = pPlan.Criteria;<br />
 dr[NetworkKeywords._cParameter] = pPlan.Parameter;<br />
 dr[NetworkKeywords._cValue] = pPlan.Value;<br />
 dr[NetworkKeywords._cUnit] = pPlan.Unit;<br />
 _dtPplan.Rows.Add(dr);<br />
}<br />
_dtPplan.AcceptChanges();<br />
<br />
_currencyManager = (CurrencyManager)this.BindingContext[dgPplan.DataSource, dgPplan.DataMember];     <br />


I really need help on this. This datagrid/datatable is driving me crazy.

Thanks in andvance

Atle
AnswerRe: How to delete row in datagrid/datatable with a delete button Pin
deep74-Aug-05 0:48
deep74-Aug-05 0:48 
GeneralRe: How to delete row in datagrid/datatable with a delete button Pin
Atlemann4-Aug-05 3:06
Atlemann4-Aug-05 3:06 
GeneralRe: How to delete row in datagrid/datatable with a delete button Pin
Alomgir Miah4-Aug-05 4:26
Alomgir Miah4-Aug-05 4:26 
GeneralRe: How to delete row in datagrid/datatable with a delete button Pin
Atlemann4-Aug-05 20:33
Atlemann4-Aug-05 20:33 
GeneralRe: How to delete row in datagrid/datatable with a delete button Pin
Atlemann4-Aug-05 20:50
Atlemann4-Aug-05 20:50 
QuestionHow to shedule Tasks using C# ? Pin
pubududilena4-Aug-05 0:26
pubududilena4-Aug-05 0:26 
AnswerRe: How to shedule Tasks using C# ? Pin
Sean Michael Murphy4-Aug-05 3:38
Sean Michael Murphy4-Aug-05 3:38 
Generalbizarre datetime parse error ... Pin
spazzman3-Aug-05 22:32
spazzman3-Aug-05 22:32 
GeneralWeb service requests Pin
WayneScott3-Aug-05 22:24
WayneScott3-Aug-05 22:24 
GeneralHard Disk Pin
ahmad hosny3-Aug-05 21:49
ahmad hosny3-Aug-05 21:49 
GeneralRe: Hard Disk Pin
Mohamad Al Husseiny3-Aug-05 22:09
Mohamad Al Husseiny3-Aug-05 22:09 
Generalpopulating combobox Pin
deep73-Aug-05 21:04
deep73-Aug-05 21:04 
GeneralRe: populating combobox Pin
Mohamad Al Husseiny3-Aug-05 21:19
Mohamad Al Husseiny3-Aug-05 21:19 
GeneralRe: populating combobox Pin
deep73-Aug-05 21:34
deep73-Aug-05 21:34 
GeneralRe: populating combobox Pin
Mohamad Al Husseiny3-Aug-05 21:40
Mohamad Al Husseiny3-Aug-05 21:40 
GeneralRe: populating combobox Pin
deep73-Aug-05 22:53
deep73-Aug-05 22:53 
GeneralRe: populating combobox Pin
Mohamad Al Husseiny3-Aug-05 23:20
Mohamad Al Husseiny3-Aug-05 23:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.