|
Set the Opacity property of the form to some value less than 100(depends how much transparent you want )
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
It not just the transparant.
I wanted that when I open a Modal form then the back ground form color will be Faded.
just like when you click on the Shutdown button of the windows the background will be faded out
|
|
|
|
|
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
|
|
|
|
|
First one clarifying question.
Is cboMyTable really a checkbox or for example a checked listbox? If it would be a single check box your code wouldn't compile since CheckBox class doesn't have Items property.
Mika
|
|
|
|
|
Hi, yeah it's a checked listbox.
|
|
|
|
|
Okay, first point (based on documentation, which is a bit confusing after your observations)
CheckedListBox.DataSource Property
Gets or sets the data source for the control. This property is not relevant for this class
Back to your question, instead of MoveNext (which doesn't exist) you could use the indexer of Items property (well actually indexer of the ListBox.ObjectCollection class)
In VB I recall that the syntax is
cboMyTable.Item(counter)
However you could also modify the SQL statement so that you don't loop each item in the listbox, but instead you first get all the records and then match them to items. In this case you would use SQL statement like
SELECT ID, OtherID FROM tblMANYTOMANY WHERE OtherID=65
and then fill a datatable based on that and for each row found in datatable, check the corresponding item in the listbox. Although you mentioned that modifying the query wasn't the first option, this would significantly bring scalability to database operations especially if you plan to upgrade to server side database such as SQL Server
Hope this helps,
Mika
|
|
|
|
|
Hi Mika, unfortunately that didn't work.
To make it easier, and forgetting database access for a while, I can narrow it down to the following issue. Hopefully this might help you to find the root of the problem, and to identify where I'm going wrong!!!
The problem is that I have searched through the listbox properties, and cannot find a way of getting the tags from each of the items in a listbox through a FOR loop. What I would like to do is something like this:
Dim i as integer = 0<br />
<br />
For i = 0 to (MyListBox.items.count - 1)<br />
<br />
' Attempt 1 - doesn't work (Tag isn't a property of Items anyway)<br />
<br />
msgbox("The tag in this item is: " & MyListBox.Items.Tag(i))<br />
<br />
' Attempt 2 - doesn't work either (Tag is a property of the listbox, but it<br />
does not seem to like being treated as an "array")<br />
<br />
msgbox("The tag in this item is: " & MyListBox.Tag(i))<br />
<br />
Next
In both cases, the application compiles but returns an error message: "If a member in a class library has been removed, recompile any assemblies that reference that library". I am not certain what this means, but I'm guessing it is the fact that listboxes don't like their items being treated as "arrays".
I have also changed i = 0 to i = 1 in the forlorn hope that the listbox started at 1 rather than 0, but with no luck.
I'm sure there are ways around this, but I don't want to write pages of extra code if I'm just missing one line...
Thanks again, I really appreciate it!
|
|
|
|
|
I should also point out that it's a CheckedListBox, not a ListBox (hence the "checks")
|
|
|
|
|
Hi,
I've managed to fix this problem, after much gnashing of teeth...
Basically, for anyone else who runs into the same problem, here is a simple example showing how tags for items in a checkedlistbox can be displayed:
Dim n as Integer<br />
<br />
Dim str as String = ""<br />
<br />
For n = 0 to (MyCheckedListBox.Rows.Count - 1)<br />
<br />
str = str & MyCheckedListBox.Items(n)("MyTag").ToString() & " "<br />
<br />
Next<br />
<br />
Messagebox.show(str)
This assumes you have set up the tag for the item somewhere else in your code, e.g. if it's from a datatable:
MyCheckedListBox.DataSource = dtMyDataTable<br />
MyCheckedListBox.DataBindings.Add("Tag", dtMyDataTable, "MyTag")<br />
MyCheckedListBox.DataBindings.Add("Text", dtMyDataTable, "MyText")<br />
MyCheckedListBox.DisplayMember = "MyText"
To be honest, this seems a very clunky way of doing things, but that's just my opinion!
|
|
|
|
|
Doesn't seem so clunky at all.
As you noticed the problem in your previous post was that you didn't use the indexer on Items, but tried to use it on Tag property (which won't work since you are not "positioned" to any single Item).
Glad you got it solved.
Mika
|
|
|
|
|
hi to everybody, I would need an information please.
I need to distribute an application on a pendrive and
my customer doesn't want to make installations
but the problem is that I must give him a report and
I cannot use the cristal report viewer because it asks for the dll to install.
if I use the control "rdlc" for the construction of the report,
as do I do to show it without bringing me behind particular dll?
thanks for the help and good day
|
|
|
|
|
You simply don't have a choice. You either make an installation, as required by whatever reporting package you use, or you leave out the reporting. It's that simple.
|
|
|
|
|
I declared a variable name as string
I populate my combo in the selected indexchanged event
i have name = me.combox.selecteditem tostring
the name is returning system.data.datarowview
Any idea why is returning system.data.datarowview type instead of assigning
the selected name to the name variable.
|
|
|
|
|
I am confused.
Post your code please.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Sub listsponsor()
Me.CmbSponsor.DataSource = objreg.listsponsor
Me.CmbSponsor.DisplayMember = "distID"
Me.CmbSponsor.ValueMember = "distID"
End Sub
Private Sub CmbSponsor_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbSponsor.SelectedIndexChanged
Me.txtsponsorformno.Text = objreg.getsponsorformno(Me.CmbSponsor.SelectedItem.ToString)
End Sub
Me.CmbSponsor.SelectedItem.ToString returns system.data.datarow view. i also notice on step into that selectedindexchange fire bfore line 2 in sub listsponsor
|
|
|
|
|
Ebube wrote: Me.CmbSponsor.SelectedItem.ToString returns system.data.datarow view
Its due to the fact that your ComboBox is Databound.
Use SelectedText instead.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I have an ASP (classic) application, I want to call MQ series from this application. Does anyone has sample code to do this.
Issue in detail: I have 5 fields in my ASP application, when the user enters data to this field I have to validate by putting these values to MQ series queue.
If somebody can help on this it would be great.
Asheej T K
Bangalore
asheejtk@yahoo.com
|
|
|
|
|
Hi
Please tell me how we use INF Tool for making setup of any VB6 project
Amit Battan Ror
battan20@gmail.com
|
|
|
|
|
Amit Battan Ror wrote: Please tell me how we use INF Tool for making setup of any VB6 project
Look at its documentation.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I have one arraylist
where i load up all bookinfo obj
and want to return the collection of bookinfo[]
I can do it the following way in c# but I need to know how can we type cast the following in vb.net:
ArrayList a=new ArrayList();
Bookinfo obj=new BookInfo();
return (BookInfo[])a.ToArray(obj.GetType());
|
|
|
|
|
I think thi will do it :-
Dim a As New ArrayList()
Dim obj As Bookinfo = New BookInfo()
Return DirectCast(a.ToArray(obj.[GetType]()), BookInfo())
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
|
Unless you are stuck with framework 1, don't use ArrayList at all.
Use a generic list. As it's strongly typed you don't need any casting:
List<Bookinfo> a = new List<Bookinfo>();<br />
Bookinfo b = new Bookinfo();<br />
a.Add(b);<br />
return a.ToArray();
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi all URGENT!!!
I posted this a long time ago and did not get any answers. can someone please help!!!
I have a vb.net datagridview. One col has a combobox, I want to populate another cell from within the same row as the ComboBox is based on the ComboBox selection.
Eg. ComboBox.Selectedtext="Yes" then DGV.DateGiven = date.today
Can someone please help me how to do this.
modified on Tuesday, November 25, 2008 7:59 PM
|
|
|
|
|