all groups > dotnet windows forms > september 2003 >
You're in the dotnet windows forms group:
DATAGRID PROBLEMS
dotnet windows forms:
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,
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 [quoted text, click to view] "Kenneth Clive" <mclive6112@aol.com> wrote in message news:0a6501c387af$6f933210$a401280a@phx.gbl... > 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.
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. [quoted text, click to view] >-----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 > >"Kenneth Clive" <mclive6112@aol.com> wrote in message >news:0a6501c387af$6f933210$a401280a@phx.gbl... >> 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. > >.
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 [quoted text, click to view] "Kenneth Clive" <mclive6112@aol.com> wrote in message news:1a6001c38922$6c131870$a001280a@phx.gbl... > 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 > > > >"Kenneth Clive" <mclive6112@aol.com> wrote in message > >news:0a6501c387af$6f933210$a401280a@phx.gbl... > >> 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. > > > >. > >
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. [quoted text, click to view] >-----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 > >"Kenneth Clive" <mclive6112@aol.com> wrote in message >news:1a6001c38922$6c131870$a001280a@phx.gbl... >> 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 >> > >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message >> >news:0a6501c387af$6f933210$a401280a@phx.gbl... >> >> 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. >> > >> >. >> > > >.
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 [quoted text, click to view] "Kenneth Clive" <mclive6112@aol.com> wrote in message news:017d01c38a9d$23dde8b0$a401280a@phx.gbl... > 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 > > > >"Kenneth Clive" <mclive6112@aol.com> wrote in message > >news:1a6001c38922$6c131870$a001280a@phx.gbl... > >> 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 > >> > > >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message > >> >news:0a6501c387af$6f933210$a401280a@phx.gbl... > >> >> 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. > >> > > >> >. > >> > > > > >. > >
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. [quoted text, click to view] >-----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 > >"Kenneth Clive" <mclive6112@aol.com> wrote in message >news:017d01c38a9d$23dde8b0$a401280a@phx.gbl... >> 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 >> > >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message >> >news:1a6001c38922$6c131870$a001280a@phx.gbl... >> >> 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 >> >> > >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message >> >> >news:0a6501c387af$6f933210$a401280a@phx.gbl... >> >> >> 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. >> >> > >> >> >. >> >> > >> > >> >. >> > > >.
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 [quoted text, click to view] "Kenneth Clive" <mclive6112@aol.com> wrote in message news:138701c38c69$379f0910$a001280a@phx.gbl... > 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 > > > >"Kenneth Clive" <mclive6112@aol.com> wrote in message > >news:017d01c38a9d$23dde8b0$a401280a@phx.gbl... > >> 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 > >> > > >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message > >> >news:1a6001c38922$6c131870$a001280a@phx.gbl... > >> >> 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 > >> >> > > >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in > message > >> >> >news:0a6501c387af$6f933210$a401280a@phx.gbl... > >> >> >> 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. > >> >> > > >> >> >. > >> >> > > >> > > >> >. > >> > > > > >. > >
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? [quoted text, click to view] >-----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 > >"Kenneth Clive" <mclive6112@aol.com> wrote in message >news:138701c38c69$379f0910$a001280a@phx.gbl... >> 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 >> > >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message >> >news:017d01c38a9d$23dde8b0$a401280a@phx.gbl... >> >> 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 >> >> > >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message >> >> >news:1a6001c38922$6c131870$a001280a@phx.gbl... >> >> >> 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 >> >> >> > >> >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in >> message >> >> >> >news:0a6501c387af$6f933210$a401280a@phx.gbl... >> >> >> >> 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. >> >> >> > >> >> >> >. >> >> >> > >> >> > >> >> >. >> >> > >> > >> >. >> > > >.
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 [quoted text, click to view] "Kenneth Clive" <mclive6112@aol.com> wrote in message news:10f301c38d32$5504e050$a001280a@phx.gbl... > 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 > > > >"Kenneth Clive" <mclive6112@aol.com> wrote in message > >news:138701c38c69$379f0910$a001280a@phx.gbl... > >> 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 > >> > > >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message > >> >news:017d01c38a9d$23dde8b0$a401280a@phx.gbl... > >> >> 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 > >> >> > > >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in > message > >> >> >news:1a6001c38922$6c131870$a001280a@phx.gbl... > >> >> >> 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 > >> >> >> > > >> >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in > >> message > >> >> >> >news:0a6501c387af$6f933210$a401280a@phx.gbl... > >> >> >> >> 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. > >> >> >> > > >> >> >> >. > >> >> >> > > >> >> > > >> >> >. > >> >> > > >> > > >> >. > >> > > > > >. > >
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 [quoted text, click to view] >-----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 > >"Kenneth Clive" <mclive6112@aol.com> wrote in message >news:10f301c38d32$5504e050$a001280a@phx.gbl... >> 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 >> > >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message >> >news:138701c38c69$379f0910$a001280a@phx.gbl... >> >> 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 >> >> > >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message >> >> >news:017d01c38a9d$23dde8b0$a401280a@phx.gbl... >> >> >> 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 >> >> >> > >> >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in >> message >> >> >> >news:1a6001c38922$6c131870$a001280a@phx.gbl... >> >> >> >> 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 >> >> >> >> > >> >> >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in >> >> message >> >> >> >> >news:0a6501c387af$6f933210 $a401280a@phx.gbl... >> >> >> >> >> 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
Kenneth, [quoted text, click to view] > If cboTables.Text = "Stocks" Then > DataGrid1.SetDataBinding(DsDatabase1,_ > DsDatabase1.Stocks.TableName) > OleDbAdapterStocks.Fill(DsDatabase1) > Count() > End If
You are trying to bind the grid BEFORE retrieving the data. Swap these lines to make your code look like this: If cboTables.Text = "Stocks" Then OleDbAdapterStocks.Fill(DsDatabase1) Count() DataGrid1.SetDataBinding(DsDatabase1,_ DsDatabase1.Stocks.TableName) End If -- 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 [quoted text, click to view] "Kenneth Clive" <mclive6112@aol.com> wrote in message news:030d01c3905f$817d47f0$a101280a@phx.gbl... > 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 > > > >"Kenneth Clive" <mclive6112@aol.com> wrote in message > >news:10f301c38d32$5504e050$a001280a@phx.gbl... > >> 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 > >> > > >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message > >> >news:138701c38c69$379f0910$a001280a@phx.gbl... > >> >> 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 > >> >> > > >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in > message > >> >> >news:017d01c38a9d$23dde8b0$a401280a@phx.gbl... > >> >> >> 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 > >> >> >> > > >> >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in > >> message > >> >> >> >news:1a6001c38922$6c131870$a001280a@phx.gbl... > >> >> >> >> 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
Your method of fixing my error did work, but I still can't see what is in the cell while I am editing the cell's content. Whenever a cell is in focus, I cannot see anything in the cell. When I put another cell in focus, the first cell's contents come back, but the current cell's content disappears. I'm connecting to an Access 2000 database (this may relate to my problem here). Regards, Kenneth Clive. [quoted text, click to view] >-----Original Message----- >Kenneth, > >> If cboTables.Text = "Stocks" Then >> DataGrid1.SetDataBinding(DsDatabase1,_ >> DsDatabase1.Stocks.TableName) >> OleDbAdapterStocks.Fill(DsDatabase1) >> Count() >> End If > >You are trying to bind the grid BEFORE retrieving the data. Swap these lines >to make your code look like this: > >If cboTables.Text = "Stocks" Then > OleDbAdapterStocks.Fill(DsDatabase1) > Count() > DataGrid1.SetDataBinding(DsDatabase1,_ > DsDatabase1.Stocks.TableName) >End If > > >-- >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 > >"Kenneth Clive" <mclive6112@aol.com> wrote in message >news:030d01c3905f$817d47f0$a101280a@phx.gbl... >> 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 >> > >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message >> >news:10f301c38d32$5504e050$a001280a@phx.gbl... >> >> 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 >> >> > >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message >> >> >news:138701c38c69$379f0910$a001280a@phx.gbl... >> >> >> 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 >> >> >> > >> >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in >> message >> >> >> >news:017d01c38a9d$23dde8b0$a401280a@phx.gbl... >> >> >> >> 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 >> >> >> >> > >> >> >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in >> >> message
I tried your code, but it didn't stop that nagging problem about the DataGrid. I still can't see what I'm editing when a cell is in focus. I'm connected to an Access 2000 database. I have a computer running XP Home Edition on it (I should have Pro, but I'll get it later). Is there a problem with the db engine, or is there a problem with VB? Regards, Kenneth Clive. [quoted text, click to view] >-----Original Message----- >Kenneth, > >> If cboTables.Text = "Stocks" Then >> DataGrid1.SetDataBinding(DsDatabase1,_ >> DsDatabase1.Stocks.TableName) >> OleDbAdapterStocks.Fill(DsDatabase1) >> Count() >> End If > >You are trying to bind the grid BEFORE retrieving the data. Swap these lines >to make your code look like this: > >If cboTables.Text = "Stocks" Then > OleDbAdapterStocks.Fill(DsDatabase1) > Count() > DataGrid1.SetDataBinding(DsDatabase1,_ > DsDatabase1.Stocks.TableName) >End If > > >-- >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 > >"Kenneth Clive" <mclive6112@aol.com> wrote in message >news:030d01c3905f$817d47f0$a101280a@phx.gbl... >> 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 >> > >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message >> >news:10f301c38d32$5504e050$a001280a@phx.gbl... >> >> 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 >> >> > >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message >> >> >news:138701c38c69$379f0910$a001280a@phx.gbl... >> >> >> 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 >> >> >> > >> >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in >> message >> >> >> >news:017d01c38a9d$23dde8b0$a401280a@phx.gbl... >> >> >> >> 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 >> >> >> >> > >> >> >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in >> >> message >> >> >> >> >news:1a6001c38922$6c131870
Kenneth, [quoted text, click to view] > Is there a problem with the db engine, or is there a > problem with VB?
Both are unlikely. You could check the ForeColor and BackColor property values on text boxes hosted by the DataGridColumnStyle(s). You can access these checkboxes through the DataGridColumnStyle.TextBox property. I'm afraid I wouldn't be able to suggest anything else without an ability to play with the program itself. -- 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 [quoted text, click to view] "Kenneth Clive" <mclive6112@aol.com> wrote in message news:2ddfb01c3950e$418657f0$a601280a@phx.gbl... > I tried your code, but it didn't stop that nagging > problem about the DataGrid. I still can't see what I'm > editing when a cell is in focus. I'm connected to an > Access 2000 database. I have a computer running XP Home > Edition on it (I should have Pro, but I'll get it later). > Is there a problem with the db engine, or is there a > problem with VB? > > Regards, > > Kenneth Clive. > >-----Original Message----- > >Kenneth, > > > >> If cboTables.Text = "Stocks" Then > >> DataGrid1.SetDataBinding(DsDatabase1,_ > >> DsDatabase1.Stocks.TableName) > >> OleDbAdapterStocks.Fill(DsDatabase1) > >> Count() > >> End If > > > >You are trying to bind the grid BEFORE retrieving the > data. Swap these lines > >to make your code look like this: > > > >If cboTables.Text = "Stocks" Then > > OleDbAdapterStocks.Fill(DsDatabase1) > > Count() > > DataGrid1.SetDataBinding(DsDatabase1,_ > > DsDatabase1.Stocks.TableName) > >End If > > > > > >-- > >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 > > > >"Kenneth Clive" <mclive6112@aol.com> wrote in message > >news:030d01c3905f$817d47f0$a101280a@phx.gbl... > >> 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 > >> > > >> >"Kenneth Clive" <mclive6112@aol.com> wrote in message > >> >news:10f301c38d32$5504e050$a001280a@phx.gbl... > >> >> 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 > >> >> > > >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in > message > >> >> >news:138701c38c69$379f0910$a001280a@phx.gbl... > >> >> >> 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 > >> >> >> > > >> >> >> >"Kenneth Clive" <mclive6112@aol.com> wrote in > >> message > >> >> >> >news:017d01c38a9d$23dde8b0$a401280a@phx.gbl... > >> >> >> >> 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.
Don't see what you're looking for? Try a search.
|
|
|