Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i use this script to select a row from my data grid.. but he doesn't fill it.. what's wrong?

 

my customrow script

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));
		}

	}



	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..

 

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();

	
	}

  • *Experts*
Posted

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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

my script now

 

public static event CustomRowHandler CustomRow;

 

		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();

 

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

	}

 

	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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...