what's wrong? C#

rmokkenstorm

Freshman
Joined
Feb 20, 2006
Messages
31
i use this script to select a row from my data grid.. but he doesn't fill it.. what's wrong?

my customrow script
Code:
	public void dataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			int rowIndex = dataGrid1.CurrentRowIndex;
			if (CustomRow != null)
			{
				CustomRow(this, new CustomRowEventArgs(barry11,dataGrid1,rowIndex));
			}
	
		}
Code:
		public class CustomRowEventArgs : EventArgs
		{
		
			DataSet  barry11;
			DataGrid grid;
			int row;
			public CustomRowEventArgs(DataSet DSet,DataGrid Grid,int Row)
			{
				grid = Grid;
				row = Row;
				barry11 = barry11;
			}
			public DataSet DSet
			{
				get { return barry11; }
			}
			public DataGrid Grid
			{
				get { return grid; }
			}
			public int Row
			{
				get { return row; }

			}

and my code to read it out.. at least it should read it..

Code:
	public virtual void customHandler_CustomRow(object sender, CustomRowEventArgs e)
		{
			DataSet  DSet = e.DSet;
			DataGrid dataGrid1 = e.Grid;
			int row = e.Row;
		
			textBox.Text = dataGrid1[e.Row,0].ToString();

		
		}
 
I'm not sure what you're doing, but the class CustomRowEventArgs has a constructor that's doing this:
barry11 = barry11;

I think you want:
barry11 = DSet;

-ner
 
my script now

Code:
public static event CustomRowHandler CustomRow;

Code:
		public virtual void customHandler_CustomRow(object sender, CustomRowEventArgs e)
		{
			Barry1  DSet = e.DSet;
			DataGrid dataGrid = e.Grid;
			int row = e.Row;
		
			textBox2.Text=barry11.Tables[0].Rows [row]["firstname"].ToString();

Code:
		public void dataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (CustomRow != null)
			{
			CustomRow(this, new CustomRowEventArgs(barry11,dataGrid,dataGrid.CurrentRowIndex));
			}
	
		}

Code:
	public class CustomRowEventArgs : EventArgs
		{
		
			Barry1  dataSet;
			DataGrid grid;
			int row;

			public CustomRowEventArgs(Barry1 DSet,DataGrid Grid,int Row)
			{
				dataSet = DSet;
				grid = Grid;
				row = Row;
				
			}
			public Barry1 DSet
			{
				get { return dataSet; }
			}
			public DataGrid Grid
			{
				get { return grid; }
			}
			public int Row
			{
				get { return row; }
			}
	
		

	}

I really don't get it...
it runs without errors. but i cant read the row in the textbox..
what's wrong?

is the code not correct by my currentrowindex..
or is the code bad at the textbox part?
 
Back
Top