[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How can i insert a check box in each row of a DataGrid????

Posted on 2004-10-05
8
Medium Priority
?
343 Views
Last Modified: 2010-04-23
How can i insert a check box in each row of a datagrid after i put data into the datagrid with a "SELECT * FROM Table"???

And how can i refer to the rows that have the check boxes checked???

It's URGENT.

Thanks.
0
Comment
Question by:drcyrus3d
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 12226042
0
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 200 total points
ID: 12226074
>>How do I determine whether a checkbox in my datagrid is checked or not?<<
If the column is a boolean column, you can just cast the object returned by the indexer to a bool and use it.
 
If CType(dataGridTopics(row, column),Boolean) Then
     MessageBox.Show("I am true")
else  
     MessageBox.Show("I am false")
End If
0
 
LVL 3

Expert Comment

by:RacinRan
ID: 12226138
I used a table style and added my checkbox column as a DataGridBoolColumn.  I actually have mine mapped to a datasource, but this is a boolean column so no need to Ctype it.

Racin
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:drcyrus3d
ID: 12226148
I need a VB.NET example....:(
0
 
LVL 1

Author Comment

by:drcyrus3d
ID: 12226165
The previous message was for the first reply..... :D

I need some code example...pls. Thanks.
0
 
LVL 1

Author Comment

by:drcyrus3d
ID: 12226184
i found this code for checking if a checkbox is checked or not.

Private Sub GetSelections_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetSelections.Click
        Dim rowCount As Integer = 0
        Dim gridSelections As StringBuilder = New StringBuilder()

        'Loop through each DataGridItem, and determine which CheckBox controls
        'have been selected.
        Dim DemoGridItem As DataGridItem
        For Each DemoGridItem In DemoGrid.Items

            Dim myCheckbox As CheckBox = CType(DemoGridItem.Cells(0).Controls(1), CheckBox)
            If myCheckbox.Checked = True Then
                rowCount += 1
                gridSelections.AppendFormat("The checkbox for {0} was selected<br>", _
                                            DemoGrid.DataKeys(DemoGridItem.ItemIndex).ToString())
            End If
        Next
        gridSelections.Append("<hr>")
        gridSelections.AppendFormat("Total number selected is: {0}<br>", rowCount.ToString())
        ResultsInfo.Text = gridSelections.ToString()

End Sub

Now i want to know how to add that checkbox to my datagrid.
0
 
LVL 3

Assisted Solution

by:RacinRan
RacinRan earned 1800 total points
ID: 12226304
       Dim oTS As New DataGridTableStyle
        Dim oCol As New DataGridTextBoxColumn
        Dim oBoolCol as New DataGridBoolColumn

        oTS.MappingName = "MyDataSource"  'MappingName maps fields in your query to fields in the grid.

'A Field In select statement
        With oCol
            .MappingName = "Priority"
            .HeaderText = "Priority"
            .Width = 25
        End With
        oTS.GridColumnStyles.Add(oCol)

'Another Field in select statement
        With oCol
            .MappingName = "EquipReqID"
            .HeaderText = "ERID"
            .Width = 50
        End With
        oTS.GridColumnStyles.Add(oCol)

'My Bool not in in select statement, do not set mapping name
        With oBoolCol
            .HeaderText = "ERID"
            .Width = 50
        End With
        oTS.GridColumnStyles.Add(oBoolCol)

dgEquipRequest.TableStyles.Add(oTS)  'When this datasource is used for this grid, this tablestyle will be used for what you see in the grid.

Racin

0
 
LVL 1

Author Comment

by:drcyrus3d
ID: 12226799
Thanks.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question