Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, I have a small problem. I'm writing an application to access a database. I have multiple forms in the application. One form has a datagrid that displays data from a dataset. I want to be able to access the datagrid from another form to read a row selected by the user. I did this by changing the constructor of the second form to accept a datagrid, and used this constructor in the first form to pass an instance of the datagrid......I don't know if this is the right thing to do. If there is a better way to this, for example by setting the datagrid to be public, please tell me

 

Thanx in advance

 

WMZ

Proudly a Palestinian

Microsoft ASP.NET MVP

My Blog: wessamzeidan.net

  • *Experts*
Posted

Remeber that if you pass the form and you want to see the members (the controls, such as the DataGrid), you'll have to change their default protection level to public.

 

It sounds like your second form doesn't really need the grid, just some data from the selected row? If this is true, maybe the first form could extract whatever data is needed from the currently selected row and pass that to the second form. That's usually a simpler method than passing the control or Form reference. Just a thought.

 

-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

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