473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Need Advice

Hi,

I'm looking for a way to do something, and i need help on finding the best
way to do it.
I've one Form that contains a dataGrid, and one of the buttons in that form,
opens another Form which contains dataGrid that shows list of Headers (each
header represnt a Invoice which was made in the first form in the past), the
first column is a checkbox column, and what i need to do is, when the user
will press the ok button on the second form, i want to take all the the lines
of that header from the dataBase and write them into the dataGrid of the
first form. the problem i'm having is that i don't know how many checkboxes
will be checked, so i can just create variables, so what can i do to get the
lines of each header from the database and insert them to the dataGrid of the
first form?
I hope i explained my problem just enough to get some help...
Thanks,
Gidi.
Nov 17 '05 #1
1 971
This is a sorta typical 'delegate situition', heres a simple example

//Datagrid selection form, ONLY a ID and Checked data fields
public class DatagridForm : System.Windows.Forms.Form {

private System.Windows.Forms.DataGrid grdData;
private System.Windows.Forms.Button btnSelect;

GridItemSelected gridItemSelected;

public delegate void GridItemSelected(int id);

public DatagridForm(GridItemSelected gridItemSelected) {
InitializeComponent();

this.gridItemSelected = gridItemSelected;
this.btnSelect.Click += new System.EventHandler(this.SelectItem);
}

private void SelectItem(object sender, System.EventArgs e) {
if (gridItemSelected == null) {
return;
}
DataTable table = (DataTable)grdData.DataSource;
foreach(DataRow row in table.Rows) {
if (Convert.ToBoolean(row["Checked"])) {
gridItemSelected(Convert.ToInt32((row["ID"])));
}
}

}

//MainForm which fires on the datagrid form
public class MainForm : System.Windows.Forms.Form {
//...
private void btnSelectDetail_Click(object sender, System.EventArgs e) {
DatagridForm form = new DatagridForm(new
DatagridForm.GridItemSelected(this.GridItemSelecte d));
form.ShowDialog();
}

//This method is called for each of the checked data row in the grid form
void GridItemSelected(int id) {
Console.WriteLine(("[Selected]" + id);
}

//...
}

Altho the data gets passed back may vary, the idea is the same

Hope this helps
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andy | last post by:
Hello All, I'm currently getting into ASP and need some advice on any particular books or tutorials or websites that you can recommend so that I can get a good foundation on ASP as well as...
11
by: Mark | last post by:
Hi, For the last 2 years I've been developing vehicle tracking/telemetric software for a company as a self employed individual. The project is quiet big, and is going to be there flagship...
2
by: andyjgw | last post by:
Hi I'm a bit new to the designing of custom web page controls and using them in the properties designer window - need a little advice on a concept here. I have two properties in my control -...
1
by: Chris Lane | last post by:
Need Advice on prebuilt Exception Assemblies Please take a look at my post on the Titled: Need Advice on prebuilt Exception Assemblies posted on 04/21/04 Thank
3
by: Sigmathaar | last post by:
Hi, I'm need some advice about lists and vectors. I'm doing a program who needs to have sequential access of a non ordered unit of objects whose size decreases almost each time the sequence is...
4
by: Web_PDE_Eric | last post by:
I don't know where to go, or what to buy, so plz re-direct me if I'm in the wrong place. I want to do high performance integration of partial differential eqns in n dimensions (n=0,1,2,3..etc) I...
9
by: laststubborn | last post by:
Dear All, We have a big concern in our Database system. We have 2000 transactions daily in our database. We need to replicate some how the database for our fail over setup. I tried transactional...
7
by: John Paul | last post by:
I'm thinking of building an e-commerce site in php. Anyone got any advice in building one? What is the best way to implement a payment system? Are any legal issues involved? Thanks,
51
by: cool_ratikagupta | last post by:
hello friends i ha just started learning c can u all give me the tips to make myself strong in c lanuage . as i want to be the best in watever i do . so just a request from all of u here plz help...
7
by: SM | last post by:
Hello, I have a index.php template (2 columns). The right columns contains a bunch of links (interviews, poems, etc...) The left columns contains the actual article. So if I click on a link on...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.