|
Hi,
It can't figure out how to use the databinding/datasource for following situation. I have built a datamodel using xsd and a generated dataset. I want to navigate through and edit the records of a certain table. So a collection of controls is bound to the attributes of this table. Editing and navigating works fine for most of the attributes. Attributes containing the foreign key to a related table give me the problem. I have two related tables :
- Group which is a parent of the main table
- Sub Group which is a parent of the main table
- Group is also a parent of sub group
The combobox control for the foreign key field of group table is setup like this :
- Databinding : SelectedValue - Main.Group
- Datasource : Group
- DisplayMember : Name (Which is an attribute of the group table)
- ValueMember : Id (Which is an attribute of the group table)
So far so good; Navigating ok, and editing ok. ComboBox is filled with all records of group table and gets refreshed on navigating through the records in the main table.
Now I want to create a similar combobox for the foreign key field of the sub group table, but with an extra constraint. The combobox must be filled only with those records from the subgroup table which are related to the selected group. I've setup the control like this :
- Databinding : SelectedValue - Main.SubGroup
- Datasource : Group
- DisplayMember : GroupSubGroup.Name (Use the relation field)
- ValueMember : GroupSubGroup.Id (Use the relation field)
Now filtering takes place on navigation, so only relevant subgroups are included into the list of the combobox. But the selected value is always the first in the list, which is not correct and seems to result in an implicit change of the data.
I've been struggling with a lot of events as well but none of all seem to give me a clue. It pretty much looks like a the order in which things take place. So SelectedValue is updated on navigation for th SubGroup combobox and after that the list is filled with relevant records and results in selecting the first from the list.
Does anyone know a solution for this ?
|
|
|
|
|
I don't know how you created the form, but if you created with the DataForm Wizard, then try to change your FillDataSet function:
Public Sub FillDataSet(ByVal dataSet As ghard.ds_modip)
'Turn off constraint checking before the dataset is filled.
'This allows the adapters to fill the dataset without concern
'for dependencies between the tables.
dataSet.EnforceConstraints = False
Dim tabel As DataTable
Dim rec As ADODB.Recordset
tabel = dataSet.Tables("YOUR_TABLE")
Try
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to fill the dataset through the OleDbDataAdapter1.
'Here you must fill the recordset according to your tables (use the open method of the ADODB.Recordset object. For example: rec.open("select * from table1 inner join table 2 on table1.field1=table2.field2",conn,ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly); conn is a valid ADODB.connection
Me.OleDbDataAdapter1.Fill(tabel, rec)
Catch fillException As System.Exception
'Add your error handling code here.
Throw fillException
Finally
'Turn constraint checking back on.
dataSet.EnforceConstraints = True
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
In this way, you fill the data set with your data. I had the same problem as you had. This is the way i handle it.
I know it looks hard, but trust me. It isn't. If you have any questions you can write me to cosminadrianpopescu@yahoo.com
Success.
Cosmin
|
|
|
|
|
Can i use .NET assembly in MFC.
TIA
Regards
Tarun
Blue Pill or Red Pill........??
|
|
|
|
|
|
Thanks a lot for the valuable inputs...
i like your quote also
We are all wave equations in the Information Matrix of the Universe.
Nice One....
and nice site too.
Regards
Tarun
Blue Pill or Red Pill........??
|
|
|
|
|
Hi,
I have a tree view, and I provided drag and drop from one node to another. When I am moving the cursor after dragging one node(selecting), I want to highligh the node which gets the focus, I wouldlike to replicate the explorer functionality.
In explorer when we drag something and move across nodes it will highlight the node which has got current focus and if we release the mouse the dragged node contents will be dropped on to the highlighted node. In this case user will know where he is dropping exactly.
Thanks,
Sreepathi
|
|
|
|
|
Anyone know of a decent free syntax highlighting edit control for .NET?
Ryan
|
|
|
|
|
http://www.icsharpcode.net/OpenSource/SD/Default.aspx
from SharpDevelop. Pretty easily to extend and the editor itself is seperate dll that can be used.
|
|
|
|
|
Excelent thanks, should have thought of sharpdevelop, doh
Ryan
|
|
|
|
|
|
|
and DotGNU
http://www.dotgnu.org/
|
|
|
|
|
So, it's possible to run a .NET program compiled in MSVC# on a linux system? Can the same executeable be used? Do you know of any Linux distributions that include DotGNU?
|
|
|
|
|
Anybody got any idea's how retrieve the motherboards CPU and case temperature etc. in .net?
|
|
|
|
|
|
Dosn't the Win32_TemperatureProbe class just return information about the "thermometers" in you computer?
/\ |_ E X E GG
|
|
|
|
|
|
|
i tried to use FileStream Class but it only supports writing byte[] not even byte[,]..
anyone has a clue ?
thanx
shakooosh
|
|
|
|
|
Suppose wr is your BinaryWriter , your multidimensional (rectangular) array, theArray is 2D. Store and write the dimensions out thus (C#):
int mupper = theArray.GetUpperBound(0);
int nupper = theArray.GetUpperBound(1);
ws.Write(mupper);
ws.Write(nupper);
Then write out the bytes:
for (int i = 0; i < mupper; i++)
{
for (int j = 0; j < nupper; i++)
wr.Write(theArray[i, j]);
}
To read it back in, you do the reverse:
int mupper = rdr.ReadInt32();
int nupper = rdr.ReadInt32();
byte[,] theArray = new byte[mupper, nupper];
for (int i = 0; i < mupper; i++)
{
for (int j = 0; j < nupper; i++)
theArray[i, j] = rdr.ReadByte();
}
The problem is that this is not that efficient. If, however, you used a jagged array (actually, the secondary array never differs in length so for all purposes it's still rectangular not jagged,) you can define theArray 2d, m,n like this:
byte[][] theArray = new byte[m][];
for (int i = 0; i < theArray.Length; i++)
theArray[i] = new byte[n];
You access the byte at x, y thus: theArray[x][y]
Saving is a lot more efficient using a jagged array:
wr.Write(theArray.Length);
wr.Write(theArray[0].Length);
for (int i = 0; i < theArray.Length; i++)
wr.Write(theArray[i]);
Reading back in is also more efficient:
int m = rdr.ReadInt32();
int n = rdr.ReadInt32();
byte[][] theArray = new byte[m][];
for (int i = 0; i < theArray.Length; i++)
theArray[i] = rdr.ReadBytes(n);
The jagged array code will also save non-rectangular arrays without modification.
|
|
|
|
|
the problem is the array is not an array of bytes..
it's an array of type double, declared this way:
" double arr[,] x; "
and the method "Write()" takes array of bytes as an argument...
thanx for replying
shakoosh
|
|
|
|
|
Using a jagged array instead of a rectangular one as above will do the trick. You just use double[][] x instead of double[,] x . See above. The code that would change would be the array initializers and accessors. If this is too much retrofit for the code, use the rectangular dual for loop method above.
|
|
|
|
|
you need to devise your own save/load algorithm
for example
<br />
for ( int i = myArray.GetLowerBound(0); i <= myArray.GetUpperBound(0); i++ )<br />
for ( int j = myArray.GetLowerBound(1); j <= myArray.GetUpperBound(1); j++ )<br />
myFileStream.WriteByte(byte.Parse(myArray.GetValue( i, j ).ToString()) );<br />
don't take my word on the syntax .... but you get the idea
|
|
|
|
|
Hi i want to access exchane server services through .NET ,
Does it have some object model sort
please guide
P.S. PATWAL
|
|
|
|
|
Hi,
I have an application which opens and saves word document from vb.net(windows) application.
I open a document directly let us say TestReport.doc, I didn't closed and minimised the same. Now I run the .NET application and in the save dialog box I gave the same file name and path, then the application is hang up. Can any one guide me how to handle the same.
Thanks,
Sreepathi
|
|
|
|