Click here to Skip to main content
15,887,350 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionform name as a property of a custom control Pin
Randana9-Sep-08 4:38
Randana9-Sep-08 4:38 
AnswerRe: form name as a property of a custom control Pin
Manas Bhardwaj9-Sep-08 4:40
professionalManas Bhardwaj9-Sep-08 4:40 
GeneralRe: form name as a property of a custom control Pin
Randana9-Sep-08 4:45
Randana9-Sep-08 4:45 
AnswerWhy just the form name? Pin
Gregory Gadow9-Sep-08 8:05
Gregory Gadow9-Sep-08 8:05 
QuestionCreate a Semi Background Transparant Form Pin
pdnet9-Sep-08 3:58
pdnet9-Sep-08 3:58 
AnswerRe: Create a Semi Background Transparant Form Pin
Manas Bhardwaj9-Sep-08 4:13
professionalManas Bhardwaj9-Sep-08 4:13 
GeneralRe: Create a Semi Background Transparant Form Pin
pdnet9-Sep-08 19:15
pdnet9-Sep-08 19:15 
QuestionChecking "previously checked" items in a checkbox Pin
C0ley9-Sep-08 3:32
C0ley9-Sep-08 3:32 
Hi folks, I hope someone can help me with a VB.NET problem, as it has been driving me bananas all day.

I have a checkbox which is binded to a datatable. Some example code is shown below:


' Access the database<br />
strSQL = "SELECT ID, Name FROM tblMYTABLE"<br />
cnnData.ConnectionString = "[information about my Microsoft Access database]"<br />
cnnData.open()<br />
daData = new OleDb.OleDbDataAdapter(strSQL, cnnData)<br />
cbData = new OleDb.OleDbCommandBuilder(daData)<br />
daData.Fill(dtData)<br />
<br />
' Bind the table to the checkbox (assuming there are records in tblMYTABLE)<br />
<br />
cboMyTable.DataSource = dtData<br />
cboMyTable.DataBindings.Add("Tag", dtData, "ID")<br />
cboMyTable.DataBindings.Add("Text", dtData, "Name")<br />
cboMyTable.DisplayMember = "Name"


So far, everything is working fine - all records in the tblMYTABLE table are shown as individual checkbox items.

However, here is the problem I have been having. I have another table in the database (a many-to-many table with two fields, both of which are the primary keys of other tables) which essentially will dictate whether or not one of the checkbox items generated above is checked or not. To give an example, let's say tblMYTABLE contains the following records:

ID Name
-=-----
1 Jim
2 Joe
3 John
4 Jill
5 Jack

The many-to-many table contains the following IDs from tblMYTABLE (let us call this table tblMANYTOMANY, and let us assume for simplicity that OtherID doesn't matter in this case):

ID OtherID
------------
1 65
4 65
2 65


Therefore, in the checkbox above, I would want to show the items relating to Jim, Jill and Joe as being ticked. I would like this to be done either during the binding process itself (i.e. within the code shown above) or as a separate piece of code immediately afterwards which goes through each of the items and checks them off as necessary, but for the life of me I've no idea how this would be done.

What I would like to do is something like this:

Dim i as integer<br />
<br />
For i = 0 to (cboMyTable.Items.Count - 1)<br />
<br />
strSQL_SecondSQL = "SELECT ID, OtherID FROM tblMANYTOMANY WHERE OtherID=65 AND ID=" & cboMyTable.Items.Tag<br />
<br />
' Open the table, if there is a record there then check the item, if not, leave it as unchecked <br />
<br />
Next


The problem above is that there is no "movement" through the items (or none that I can see), i.e. there is no movement from the first item to the second, the second to the third and so on. I suppose the other way of doing it would be something like (using ASP-style script):

while not (cboMyTable.Items.Count - 1)<br />
<br />
     ' My code<br />
<br />
     cboMyTable.Item.MoveNext<br />
<br />
wend


However, there is no MoveNext property.

I know I could probably use arrays, or to change the original SQL statement, but I don't want to over-complicate the code if it is just a simple thing to fix...

Sorry this sounds very confusing - I hope someone can help!

c0ley
AnswerRe: Checking "previously checked" items in a checkbox Pin
Wendelius9-Sep-08 9:09
mentorWendelius9-Sep-08 9:09 
GeneralRe: Checking "previously checked" items in a checkbox Pin
C0ley9-Sep-08 9:46
C0ley9-Sep-08 9:46 
GeneralRe: Checking "previously checked" items in a checkbox Pin
Wendelius9-Sep-08 10:10
mentorWendelius9-Sep-08 10:10 
GeneralRe: Checking "previously checked" items in a checkbox Pin
C0ley10-Sep-08 0:05
C0ley10-Sep-08 0:05 
GeneralRe: Checking "previously checked" items in a checkbox Pin
C0ley10-Sep-08 0:14
C0ley10-Sep-08 0:14 
GeneralFIXED - Checking "previously checked" items in a checkbox Pin
C0ley10-Sep-08 2:20
C0ley10-Sep-08 2:20 
GeneralRe: FIXED - Checking "previously checked" items in a checkbox Pin
Wendelius10-Sep-08 8:26
mentorWendelius10-Sep-08 8:26 
QuestionReport with vb-net Pin
zagari9-Sep-08 1:04
zagari9-Sep-08 1:04 
AnswerRe: Report with vb-net Pin
Dave Kreskowiak9-Sep-08 6:55
mveDave Kreskowiak9-Sep-08 6:55 
Questionsystem.data.datarowview as string Pin
Ebube9-Sep-08 0:56
Ebube9-Sep-08 0:56 
AnswerRe: system.data.datarowview as string Pin
Manas Bhardwaj9-Sep-08 1:35
professionalManas Bhardwaj9-Sep-08 1:35 
GeneralRe: system.data.datarowview as string Pin
Ebube9-Sep-08 3:37
Ebube9-Sep-08 3:37 
GeneralRe: system.data.datarowview as string Pin
Manas Bhardwaj9-Sep-08 3:52
professionalManas Bhardwaj9-Sep-08 3:52 
QuestionHow to invoke MQ series through classic ASP Pin
Member 26856239-Sep-08 0:05
Member 26856239-Sep-08 0:05 
QuestionHow we use INF-Tool for making setup Pin
Amit Battan Ror8-Sep-08 21:18
Amit Battan Ror8-Sep-08 21:18 
AnswerRe: How we use INF-Tool for making setup Pin
Manas Bhardwaj8-Sep-08 21:30
professionalManas Bhardwaj8-Sep-08 21:30 
Questiontype cast in vb.net Pin
rprateek8-Sep-08 17:51
rprateek8-Sep-08 17:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.