Well, I did what you said, but I still can't see what I
am editing in the cells of the DataGrid. I have these
lines of code in a If...Then statement:
If cboTables.Text = "Stocks" Then
DataGrid1.SetDataBinding(DsDatabase1,_
DsDatabase1.Stocks.TableName)
OleDbAdapterStocks.Fill(DsDatabase1)
Count()
End If
"Count" is a procedure I created that sets a label that
shows your position and the total number of records
("Record 1 of 32"). What is wrong?
Regards,
Kenneth Clive
-----Original Message-----
Kenneth,
The TableName property is the one that should be passed
as the DataMember.
So your binding code should look like:
DataGrid1.SetDataBinding(DsDatabase1, _
DsDatabase1.Stocks.TableName)
(assuming Stocks is a property of a typed dataset
returning a DataTable
instance).
Note that the first parameter is the DataSet itself, not
a string like in
the snippets you have given. That approach wouldn't work
indeed.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
Well, I tried your suggestion with this code:
DataGrid1.SetDataBinding("DsDatabase1",
DsDatabase1.Stocks)
But, an error came up while coding that said the second
argument's value couldn't be converted to a String,
which
is what that second argument requires. Here's what I
did
next:
DataGrid1.SetDataBinding("DsDatabase1",
DsDatabase1.Stocks.TableName)
That didn't work either, because I used pretty much the
same method that I used with the combobox's text
property. You said to use the corresponding DataTable's
name, but that's not a string; it's a DataTable object
type. What should I do?
-----Original Message-----
The DataMember value should be equal to the
corresponding DataTable's Name
property value. I assume your combo box enumerates a
kind of "display"
names, and these won't do as DataMember values.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
I need yet more help! I did exactly what you
suggested,
but this error message popped up when I tested my
program:
An unhandled exception of
type 'System.ArgumentException'
occurred in system.windows.forms.dll
Additional information: Can't create a child list
for
field Members.
This popped up everytime when I selected a table,
ANY
table. Am I doing this right, Dmitriy?:
DataGrid1.SetDataBinding("DsDatabase1",
cboTables.Text)
The Datasource is my dataset, and the datamember is
the
current text that the combobox is displaying. Is
something wrong?
Sincerely,
Kenneth Clive.
-----Original Message-----
Kenneth,
I beleive the SetDataBinding method has two
overloads,
and the one you need
accepts two arguments: the data source and the data
member. The data source
will always be the same, that's right, but the data
member will be different
each time the user chooses another table in the
combobox.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
message
Dear Dmitry,
Well, what I do with the DataGrid when the user
chooses
an item in the ComboBox is to re-set the
DataGrid's
DataMember property to the corresponding table.
So,
along
with this property setting, I should use the
SetDataBinding method.
Also, I only have one DataSource, which is my
lone
dataset, DsDatabase1. Should I just do this, even
though
it will stay the same?:
.SetDataBinding(DsDatabase1)
Regards,
Kenneth Clive.
-----Original Message-----
I assume you re-bind the grid every time the
user
switches to another table
in the combobox? If this is the case, ensure you
use
the
SetDataBinding
method to re-bind the grid to a new data source.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
message
[email protected]...
Yes, I do. But, my code does not mess with how
the
grid
looks. I use a combobox so that the user can
choose
which
table to view and/or update.
-----Original Message-----
Hi Kenneth,
Do you do any programmatic customizations to
the
DataGrid?
Do you use custom table styles and/or column
styles?
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET
IDE
message
[email protected]...
I've had a problem with one of the
DataGrids
in
my
program that's been a thorn in my side for
FIVE
WEEKS!
Whenever I click on a cell in the DataGrid
to
edit
or
update a record, the cell goes blank. I can
edit,
but I
CAN'T SEE WHAT I'M DOING! I checked the
SelectionColor
properties: the back color and front color
were
fine. I
don't know if this has to do with it. I
get an
error
message when I try to write updates back to
the
original
database (database was created in Access
2000):
An unhandled exception of
type 'System.Data.OleDb.OleDbException'
occurred
in
system.data.dll
What's the problem, and how do I fix it?
Regards,
Kenneth Clive.
.
.
.
.
.