Row selection in datagrid

  • Thread starter Thread starter Andy
  • Start date Start date
Hi, Miha
I'v already tried this, but PositionChanged event is triggered only once,
after datasource was filled.

Here is my code fragment:

public class MyForm : System.Windows.Forms.Form {
.....
public MyForm()
{
InitializeComponent();
this.BindingContext[this.dsWS1,"GIN_SERVICE"].PositionChanged
+= new EventHandler(this.Pos_Changed);
...
}

private void Pos_Changed(object sender,System.EventArgs e)
{

MessageBox.Show(this.BindingContext[this.dsWS1,"GIN_SERVICE"].Position.ToStr
ing());
}

}

Is anything wrong?



Miha Markic said:
Hi Andy,

I would implement BindingManagerBase.PositionChanged event.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Andy said:
How to catch row selection in datagrid?
TIA
 
Hi Andy,

Do show me the code that binds data to grid - parameters should be the same
for binding and BindingContext

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Andy said:
Hi, Miha
I'v already tried this, but PositionChanged event is triggered only once,
after datasource was filled.

Here is my code fragment:

public class MyForm : System.Windows.Forms.Form {
.....
public MyForm()
{
InitializeComponent();
this.BindingContext[this.dsWS1,"GIN_SERVICE"].PositionChanged
+= new EventHandler(this.Pos_Changed);
...
}

private void Pos_Changed(object sender,System.EventArgs e)
{

MessageBox.Show(this.BindingContext[this.dsWS1,"GIN_SERVICE"].Position.ToStr
ing());
}

}

Is anything wrong?



Miha Markic said:
Hi Andy,

I would implement BindingManagerBase.PositionChanged event.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Andy said:
How to catch row selection in datagrid?
TIA
 
Hi Miha,
thanks for help, data binding was different:
this.dataGridWS.DataMember = "";
this.dataGridWS.DataSource = this.dsWS1.GIN_SERVICE;

I changed code to:
this.BindingContext[this.dsWS1.GIN_SERVICE].PositionChanged
+= new
EventHandler(this.Pos_Changed); ....
It works OK.


Miha Markic said:
Hi Andy,

Do show me the code that binds data to grid - parameters should be the same
for binding and BindingContext

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Andy said:
Hi, Miha
I'v already tried this, but PositionChanged event is triggered only once,
after datasource was filled.

Here is my code fragment:

public class MyForm : System.Windows.Forms.Form {
.....
public MyForm()
{
InitializeComponent();
this.BindingContext[this.dsWS1,"GIN_SERVICE"].PositionChanged
+= new EventHandler(this.Pos_Changed);
...
}

private void Pos_Changed(object sender,System.EventArgs e)
{
MessageBox.Show(this.BindingContext[this.dsWS1,"GIN_SERVICE"].Position.ToStr
ing());
}

}

Is anything wrong?



Miha Markic said:
Hi Andy,

I would implement BindingManagerBase.PositionChanged event.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

How to catch row selection in datagrid?
TIA
 
Back
Top