Check Boxes in Datagrid

ali shah

Member
Joined
Jan 13, 2005
Messages
10
Programming Experience
Beginner
hi
i am new user of vb.net and my first assignment is product management system
and the requirement is that if the user wants to place order he press a button and go to the other form and there is a combobox displaying the name of the supplier and by selecting the supplier name from the combobox the products available from the supplier should appear in the datagrid with all the information and user check the required product with a check box and closes the form and the value of the product is shown in the calling form.

i want to know that how can i add the checkboxcol in the datagrid and assign the checked value to the global variable

if any one can help me i will really appretiate with the core of mt heart

best regards
 
Hi,
u can get this through..........

1> Add a dataColumn in ur Datatable which in bind with Grid with default value as that of the Value of ur Global Variable.
2>Add "DataGridBoolColumn" columnStyle in u r DataGrid'sTable Style


I hopw this will solve ur problem.........................

Regards,
Ritesh
 
thank you ritesh for replying me but i m very sorry tht i m very new to vb.net

so could not understand your reply though i have added a "datagridboolcolumn" in the datagrid now i want that if i check this column then i can store values of that row to the global variables then i will use that values to the other forms

regards
 
Hi ALi,
first: did u got the Check box in ur Grid??

Second : as u mention , user Select Check box and close the form and than u will pass the Status of Check box through GLobal Variable is that mean that User can select only one Record at a time?? What if he has Selected Multiple Records before Closing Form??
 
hi ritesh

thanx for your guidence again now i thing i should go for the listbox instead for the datagrid and then populate the records in the textfields so that user can select only one record is it right?

regards
 
Hi,
see u can go by any control but thing is that in both case u have to manually reset the check box of listbox /Grid (by Looping through the Records)once user change it mind and select another record.....................

Reagrds,
Ritesh
 
yes i have to manually populate the list and in my dataadapter i have the following query


SELECT Supplier.Supplier_name, Product.Product_Id, Product.Product_Name, Product.unitprice, Product.descp, Product.sup_stockcode
FROM Product LEFT OUTER JOIN
Supplier ON Product.Supplier_Id = Supplier.Supplier_id
WHERE (Product.sup_stockcode LIKE @ + '%')

and then to populate the list i have this one
behind the button click

Me.daselectproduct.SelectCommand.Parameters(0).Value = Me.txtload.Text

Me.Dsselectproduct1.Clear()

Me.daselectproduct.Fill(Me.Dsselectproduct1)

is it ok or not?
 
simple If statement for Checkbox

Here is a simple if statement for a checkbox (if the check state changes), update and add code as necessary...

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
CheckBox1.Text = "True"
CheckBox1.ForeColor = System.Drawing.Color.Green
Else
CheckBox1.Text = "False"
CheckBox1.ForeColor = System.Drawing.Color.Red
End If
End Sub
 
Hi

thank you very much ritesh you have helped me a lot today ,
yes it is working and hopefully when i need the help in future
you will not mind

thanx a lot again and sorry to disturb you too

Ali
 
Back
Top