|
hi
i am facing one problem at the time of desinging 2 combobox from one datasource & one datatable. my data table contains following fields -
item_code | length | rate
xyz | 1000.00 | 2.0
bnm | 500.00 | 1.0
qwe | 300.00 | 0.50
i have to select rate for the selected item code & selected length. for this i am desiging two combobox separately but after selection of 2nd combo popup contents of 1st combo clearing. is there any solution using multicolumn combo or datagridview in 2005 ? if yes - how?
plz. help me
Thanks
bye
|
|
|
|
|
Each combo requires its own separate dataview as the datasource. The two dataviews 'point' to the same table. If you don't do this then each combo is using the table's default dataview as the datasource and a selection in one combo then affects the contents of the other.
-- modified at 10:26 Sunday 19th August, 2007
|
|
|
|
|
hi
thanks. my problem is solved using two data sets to access same datatable twice. i was doing same datasets to access same table twice.
bye.
Thanks
bye
|
|
|
|
|
Hi,
Try this...
Dim dvItemCode as New DataView(DataTable)
Dim dvLength as New DataView(DataTable)
Dim dvRate as New DataView(DataTable)
ComboBox1.DataSource = dvItemCode
ComboBox1.DisplayMember = "Item_Code"
ComboBox1.ValueMember = "ID"
ComboBox1.DataSource = dvLength
ComboBox1.DisplayMember = "Length"
ComboBox1.ValueMember = "ID"
...
Hope this helps
|
|
|
|
|
hi
thanks for immed. reply & sorry for late reply
i have done like u said but it shows one error -
Error - 'can not bind to the new display member.'
ParameterName : newdisplaymember
my code is as follows -
con.connectionstring = con_str
da_combo1.selectcommand =new sqlclient.sqlcommand
da_combo1.selectcommand.connection = con
str_sql = "select * from dbo.rate_mas"
da_combo1.selectcommand.commandtext = str_sql
da_combo1.fill(ds,"rate_mas")
dim dt as datatable = new datatable("rate_mas")
dim dvitemcode as new dataview(dt)
dim dvlength as new dataview(dt)
dim dvrate as new dataview(dt)
combo1.datasource = dvitemcode
combo1.displaymember = "item_desc"
**** it shows the above said error for immed. following stmt
combo1.valuemember = "item_code"
******** error end
combo1.datasource = dvlength
combo1.displaymember = "length"
combo1.valuemember = "id"
what can i do to solve this error
bye
Thanks
bye
|
|
|
|
|
Hi,
first please make sure that you are not trying to assign columns of two different tables to ValueMember and DisplayMember. In your case you have to check that item_desc and item_code belong to rate_mas datatable.
Good luck
|
|
|
|
|
I am trying to use VB.Net as a front end for a MS Access database. I am trying to get the date/time into a format I want to use(displaying, modifying etc). I have the field in Access defined as date/time. I only want to use the time portion in 24hr format. My format is HH:nn:ss and the input mask reflects this. When I display one record in VB.Net, the date is the only thing that is showing and instead of showing today's date, it is showing a date from 30 Dec 1899. The data I already have stored in the Access database for that field is 23:55:00. What do I need to do in order to get it to work the way I would like?
|
|
|
|
|
You are displaying the date in the text box in the wrong format. You can reformat the date in a textbox like this:
Dim MyDate As DateTime = Me.TextBox1.Text
Me.TextBox1.Text = MyDate.ToLongTimeString()
How did you setup the Dataset, etc? (Wizard or code) There is probably a better way of doing it if you could explain.
Green2Go
|
|
|
|
|
I set up the dataset through a wizard. The only thing I have coded an event on closing to update the database.
Public Class frmSingle
Private Sub DataBindingNavigatorSaveItem_Click(ByVal _ sender As System.Object, ByVal e As System.EventArgs) _ Handles DataBindingNavigatorSaveItem.Click
Me.Validate()
Me.DataBindingSource.EndEdit()
Me.DataTableAdapter.Update _(Me.TandemsheetsDataSet.data)
End Sub
Private Sub frmSingle_FormClosing(ByVal sender As Object, _ ByVal e As System.Windows.Forms.FormClosingEventArgs) _ Handles Me.FormClosing
Me.DataTableAdapter.Update _(Me.TandemsheetsDataSet.data)
End Sub
Private Sub frmSingle_Load(ByVal sender As _ System.Object, ByVal e As System.EventArgs) Handles _ MyBase.Load
'TODO: This line of code loads data into
'the 'TandemsheetsDataSet.data' table. You can
'move, or remove it, as needed.
Me.DataTableAdapter.Fill _ (Me.TandemsheetsDataSet.data)
End Sub
End Class
|
|
|
|
|
Does your format really have "nn", or is that just a typo?
Tom Garth
Developer
R. L. Nelson and Associates, Inc., Virginia
|
|
|
|
|
It was "nn" because that is what Access used as the minute placeholder in the custom format. Access probably uses it to distinguish from the month for which it uses mm. At least it is working that way.
I think I might have found what I am looking for though.
In VB on the properties for the textbox I am using, I changed the Format property to Custom and changed the CustomFormat property to HH:mm:ss. It works the way I want it to now. Thanks to Tom and green2go for attempting to help me.
|
|
|
|
|
hello everyone..
i have a little problem with loading wmf file (wmf is richtext format)
if loads from file everithing works
Dim i As Image = Image.FromFile("c:\1.wmf")
but if loads from memory array nothing happen
Dim s1 As New MemoryStream()
Dim a() As Byte
Dim i As Image
a = My.Computer.FileSystem.ReadAllBytes("c:\1.wmf")
s1.Write(a, 0, a.Length)
i = Image.FromStream(s1, True, True)
if i switch file to bmp or jpg everythings fine
please help
|
|
|
|
|
Hi,
a stream has some kind of pointer inside of it, telling it where the next
read or write is going to happen. Where do you think it points after
you did s1.Write(a, 0, a.Length) ? Read up on MemoryStream to find the cure !
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
thank you.. everything is OK now
but i dont understand why jpg works fine?!
|
|
|
|
|
Spejlo wrote: but i dont understand why jpg works fine?!
with exactly the same code ???
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
yes.. only file change to jpg
|
|
|
|
|
Hi,
MSDN on Image.FromStream() states: The stream is reset to zero if this method is
called successively with the same stream.
I did test this on a stream containing two JPEG; and later two GIF; it always
reads the first image twice, i.e. I can't read the second image !!
I don't have WMF in stock.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
A WMF is not an image, it's vector information. The Metafile class is what he needs to use.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi Christian,
I was not aware of the Metafile class, but it seems to inherit from Image.
And Wmf is just one of the ImageFormat members. So I would expect it to behave
like Jpeg and Gif as far as FromFile and FromStream go, but that is not what
the original poster was saying.
I'll try with some WMF files soon.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
So, I'd expect an Image instance can be a Metafile, but you probably need to call the Metafile constructor, or FromFile method, to load a metafile.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
To load an image, set the PictureBox's Image property to a new Bitmap object initialized by the image file's name.
' Load a file.
Private Sub mnuFileOpen_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
mnuFileOpen.Click
If dlgOpen.ShowDialog() = DialogResult.OK Then
picImage.Image = New Bitmap(dlgOpen.FileName)
Me.Width = picImage.Width + Me.Width - _
Me.ClientSize.Width
Me.Height = picImage.Height + Me.Height - _
Me.ClientSize.Height
Dim file_name As String = dlgOpen.FileName
file_name = _
file_name.Substring(file_name.LastIndexOf("\") _
+ 1)
Me.Text = "[" & file_name & "]"
dlgSave.FileName = dlgOpen.FileName
End If
End Sub
http://www.thehitcounters.com
Free Hit Counter, Website Counters by The Hit Counters
Custom Logo Design Services by http://www.thebusinesslogo.com
modified on Wednesday, May 6, 2009 6:16 AM
|
|
|
|
|
Hi John,
The OP has a problem with Image.FromStream not being consistent, and not conforming
to its documentation.
We all know how to read an image file and how to display it, that was not the issue.
BTW: some of us don't like a PictureBox much.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
A windows metafile is not a raster image, I'd be surprised that you could load it into an Image object. It contains vector information, not a picture.
http://msdn2.microsoft.com/en-us/library/wb42xhfh.aspx[^] shows how to work with a metafile.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I have been experimenting with the following C# code:
ADDED
remark: the wmf files are derived from the gif files (with Image.FromFile
and Image.Save); the jpg files are unrelated.
/ADDED
public void test() {
testImageStream("image1.gif", "image2.gif");
testImageStream("image1.jpg", "image2.jpg");
testImageStream("image1.wmf", "image2.wmf");
}
public void testImageStream(string file1, string file2) {
log(new string('-', 80));
log("First create one stream containing two images");
MemoryStream ms=new MemoryStream();
byte[] bytes1=File.ReadAllBytes(file1);
int len1=bytes1.Length;
log("file1="+file1+", len="+len1+", size="+Image.FromFile(file1).Size);
ms.Write(bytes1, 0, len1);
byte[] bytes2=File.ReadAllBytes(file2);
int len2=bytes2.Length;
log("file2="+file2+", len="+len2+", size="+Image.FromFile(file2).Size);
ms.Write(bytes2, 0, len2);
try {
log("trying without rewind, should fail");
Image img1=Image.FromStream(ms);
log(" img1="+img1.Size);
} catch(Exception exc) {
log(exc);
}
try {
log("with explicit positioning");
ms.Seek(0, SeekOrigin.Begin);
Image img1=Image.FromStream(ms);
ms.Seek(len1, SeekOrigin.Begin);
Image img2=Image.FromStream(ms);
log(" img1="+img1.Size+" img2="+img2.Size);
} catch(Exception exc) {
log(exc);
}
try {
log("with only one rewind");
ms.Seek(0, SeekOrigin.Begin);
Image img1=Image.FromStream(ms);
Image img2=Image.FromStream(ms);
log(" img1="+img1.Size+" img2="+img2.Size);
} catch(Exception exc) {
log(exc);
}
}
and this is the output it generates on VS2005 or .NET 2.0:
23:46:13.437 --------------------------------------------------------------------------------
23:46:13.453 First create one stream containing two images
23:46:13.468 file1=image1.gif, len=4315, size={Width=64, Height=131}
23:46:13.468 file2=image2.gif, len=1525, size={Width=40, Height=40}
23:46:13.484 trying without rewind, should fail
23:46:13.500 img1={Width=64, Height=131}
23:46:13.515 with explicit positioning
23:46:13.515 img1={Width=64, Height=131} img2={Width=64, Height=131}
23:46:13.531 with only one rewind
23:46:13.625 img1={Width=64, Height=131} img2={Width=64, Height=131}
23:46:13.640 --------------------------------------------------------------------------------
23:46:13.656 First create one stream containing two images
23:46:13.656 file1=image1.jpg, len=7766, size={Width=143, Height=176}
23:46:13.796 file2=image2.jpg, len=148762, size={Width=632, Height=868}
23:46:13.812 trying without rewind, should fail
23:46:13.828 img1={Width=143, Height=176}
23:46:13.843 with explicit positioning
23:46:13.843 img1={Width=143, Height=176} img2={Width=143, Height=176}
23:46:13.859 with only one rewind
23:46:13.875 img1={Width=143, Height=176} img2={Width=143, Height=176}
23:46:13.984 --------------------------------------------------------------------------------
23:46:14.000 First create one stream containing two images
23:46:14.015 file1=image1.wmf, len=4283, size={Width=64, Height=131}
23:46:14.031 file2=image2.wmf, len=1591, size={Width=40, Height=40}
23:46:14.125 trying without rewind, should fail
23:46:14.140 img1={Width=64, Height=131}
23:46:14.156 with explicit positioning
23:46:14.156 img1={Width=64, Height=131} img2={Width=64, Height=131}
23:46:14.359 with only one rewind
23:46:14.375 img1={Width=64, Height=131} img2={Width=64, Height=131}
so my conclusions are:
1. all image types tested behave identically
2. they all always rewind the stream, which is not how I understand the
documentation "The stream is reset to zero if this method is called successively
with the same stream."
It really seems to be "The stream is reset to zero then read".
3. I fail to see how your original post matches with my test.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
here is my code. comments inside.
http://lamernet.no-ip.com:45173/bordel/wmf.zip
-- modified at 3:57 Sunday 19th August, 2007
|
|
|
|
|