C# DataGridView rows are not displaying- Windows Form is broken
Currently my form has a Datagirdview(DGV) that does not have any values inside the DGV when displayed.
The column headings had to be inserted manually after the code did not work, however, the exact code worked on an older project of mine.
Code (The DGV is called dgvQuestions):
DataTable Test = new DataTable();
Test.Columns.Add("Text", typeof(string));
Test.Columns.Add("Advice", typeof(string));
Test.Columns.Add("Choice One", typeof(string));
Test.Columns.Add("Choice Two", typeof(string));
Test.Columns.Add("Choice Id (Determines Answer)", typeof(int));
dgvQuestions.DataSource = Test;
I am not sure if the form is somewhat broken as I have never seen a DGV so challenging to insert data to.
To insert data the code I used was:
dgvQuestions.Rows.Add(1, "2x2", "Count with your fingers", "4", "9", 1);
Does anyone know how to check if the DGV is locked and doesn't accept modifications? or just what the problem is...
--------------------------------UPDATE---------------------------------------
The code that has been defined as an answer did not work in my form, and textboxes values were constantly valued at "" despite there being characters inside the textbox. How do you fix a form that dosesn't accept inputs?
c#
add a comment |
Currently my form has a Datagirdview(DGV) that does not have any values inside the DGV when displayed.
The column headings had to be inserted manually after the code did not work, however, the exact code worked on an older project of mine.
Code (The DGV is called dgvQuestions):
DataTable Test = new DataTable();
Test.Columns.Add("Text", typeof(string));
Test.Columns.Add("Advice", typeof(string));
Test.Columns.Add("Choice One", typeof(string));
Test.Columns.Add("Choice Two", typeof(string));
Test.Columns.Add("Choice Id (Determines Answer)", typeof(int));
dgvQuestions.DataSource = Test;
I am not sure if the form is somewhat broken as I have never seen a DGV so challenging to insert data to.
To insert data the code I used was:
dgvQuestions.Rows.Add(1, "2x2", "Count with your fingers", "4", "9", 1);
Does anyone know how to check if the DGV is locked and doesn't accept modifications? or just what the problem is...
--------------------------------UPDATE---------------------------------------
The code that has been defined as an answer did not work in my form, and textboxes values were constantly valued at "" despite there being characters inside the textbox. How do you fix a form that dosesn't accept inputs?
c#
1
Given the apparent nature, rather than a DataTable you could use a collection like BindingList and life would be all kittens and rainbows
– Make StackOverflow Good Again
Nov 15 '18 at 23:09
So... You are creating a DataTable and adding some columns to it (but no data). Then you have a DGV, and you are setting its DataSource to your empty data table, but adding a row to the DGV (even though it has a data source). You need to pick either a) use data binding or b) add stuff manually. In addition: why are you using a data table, why not a collection of strongly typed objects, for example?
– Flydog57
Nov 15 '18 at 23:10
I am not adding data to the grid yet, as the column headings will not work. The data will be extracted from a database and placed in the DGV. The code in the 'Answer' does not work on the DGV inside the Form.
– NodeCode
Nov 15 '18 at 23:31
If you have a database it is not your job to put data in the datatable. Use a DBCommand object or a DataAdapter to fill the table. You are doing everything the hardest way possible
– Make StackOverflow Good Again
Nov 15 '18 at 23:38
I have inserted the data from my database into lists (that are used in other forms) to make it more robust and work when the connection is down. The data is already inserted to the database and I don't understand how that even came up, nonetheless, the data grid view I have got to work before with roughly 12 lines of code, to insert the data once the headings have been fitted I just need to insert a for loop to iterate through the lists. I just can't get the headings to work, without manually inserting them, I suspect that the DGV in the form has editable locked or maybe I am wrong
– NodeCode
Nov 16 '18 at 0:00
add a comment |
Currently my form has a Datagirdview(DGV) that does not have any values inside the DGV when displayed.
The column headings had to be inserted manually after the code did not work, however, the exact code worked on an older project of mine.
Code (The DGV is called dgvQuestions):
DataTable Test = new DataTable();
Test.Columns.Add("Text", typeof(string));
Test.Columns.Add("Advice", typeof(string));
Test.Columns.Add("Choice One", typeof(string));
Test.Columns.Add("Choice Two", typeof(string));
Test.Columns.Add("Choice Id (Determines Answer)", typeof(int));
dgvQuestions.DataSource = Test;
I am not sure if the form is somewhat broken as I have never seen a DGV so challenging to insert data to.
To insert data the code I used was:
dgvQuestions.Rows.Add(1, "2x2", "Count with your fingers", "4", "9", 1);
Does anyone know how to check if the DGV is locked and doesn't accept modifications? or just what the problem is...
--------------------------------UPDATE---------------------------------------
The code that has been defined as an answer did not work in my form, and textboxes values were constantly valued at "" despite there being characters inside the textbox. How do you fix a form that dosesn't accept inputs?
c#
Currently my form has a Datagirdview(DGV) that does not have any values inside the DGV when displayed.
The column headings had to be inserted manually after the code did not work, however, the exact code worked on an older project of mine.
Code (The DGV is called dgvQuestions):
DataTable Test = new DataTable();
Test.Columns.Add("Text", typeof(string));
Test.Columns.Add("Advice", typeof(string));
Test.Columns.Add("Choice One", typeof(string));
Test.Columns.Add("Choice Two", typeof(string));
Test.Columns.Add("Choice Id (Determines Answer)", typeof(int));
dgvQuestions.DataSource = Test;
I am not sure if the form is somewhat broken as I have never seen a DGV so challenging to insert data to.
To insert data the code I used was:
dgvQuestions.Rows.Add(1, "2x2", "Count with your fingers", "4", "9", 1);
Does anyone know how to check if the DGV is locked and doesn't accept modifications? or just what the problem is...
--------------------------------UPDATE---------------------------------------
The code that has been defined as an answer did not work in my form, and textboxes values were constantly valued at "" despite there being characters inside the textbox. How do you fix a form that dosesn't accept inputs?
c#
c#
edited Nov 16 '18 at 0:32
NodeCode
asked Nov 15 '18 at 23:01
NodeCodeNodeCode
205
205
1
Given the apparent nature, rather than a DataTable you could use a collection like BindingList and life would be all kittens and rainbows
– Make StackOverflow Good Again
Nov 15 '18 at 23:09
So... You are creating a DataTable and adding some columns to it (but no data). Then you have a DGV, and you are setting its DataSource to your empty data table, but adding a row to the DGV (even though it has a data source). You need to pick either a) use data binding or b) add stuff manually. In addition: why are you using a data table, why not a collection of strongly typed objects, for example?
– Flydog57
Nov 15 '18 at 23:10
I am not adding data to the grid yet, as the column headings will not work. The data will be extracted from a database and placed in the DGV. The code in the 'Answer' does not work on the DGV inside the Form.
– NodeCode
Nov 15 '18 at 23:31
If you have a database it is not your job to put data in the datatable. Use a DBCommand object or a DataAdapter to fill the table. You are doing everything the hardest way possible
– Make StackOverflow Good Again
Nov 15 '18 at 23:38
I have inserted the data from my database into lists (that are used in other forms) to make it more robust and work when the connection is down. The data is already inserted to the database and I don't understand how that even came up, nonetheless, the data grid view I have got to work before with roughly 12 lines of code, to insert the data once the headings have been fitted I just need to insert a for loop to iterate through the lists. I just can't get the headings to work, without manually inserting them, I suspect that the DGV in the form has editable locked or maybe I am wrong
– NodeCode
Nov 16 '18 at 0:00
add a comment |
1
Given the apparent nature, rather than a DataTable you could use a collection like BindingList and life would be all kittens and rainbows
– Make StackOverflow Good Again
Nov 15 '18 at 23:09
So... You are creating a DataTable and adding some columns to it (but no data). Then you have a DGV, and you are setting its DataSource to your empty data table, but adding a row to the DGV (even though it has a data source). You need to pick either a) use data binding or b) add stuff manually. In addition: why are you using a data table, why not a collection of strongly typed objects, for example?
– Flydog57
Nov 15 '18 at 23:10
I am not adding data to the grid yet, as the column headings will not work. The data will be extracted from a database and placed in the DGV. The code in the 'Answer' does not work on the DGV inside the Form.
– NodeCode
Nov 15 '18 at 23:31
If you have a database it is not your job to put data in the datatable. Use a DBCommand object or a DataAdapter to fill the table. You are doing everything the hardest way possible
– Make StackOverflow Good Again
Nov 15 '18 at 23:38
I have inserted the data from my database into lists (that are used in other forms) to make it more robust and work when the connection is down. The data is already inserted to the database and I don't understand how that even came up, nonetheless, the data grid view I have got to work before with roughly 12 lines of code, to insert the data once the headings have been fitted I just need to insert a for loop to iterate through the lists. I just can't get the headings to work, without manually inserting them, I suspect that the DGV in the form has editable locked or maybe I am wrong
– NodeCode
Nov 16 '18 at 0:00
1
1
Given the apparent nature, rather than a DataTable you could use a collection like BindingList and life would be all kittens and rainbows
– Make StackOverflow Good Again
Nov 15 '18 at 23:09
Given the apparent nature, rather than a DataTable you could use a collection like BindingList and life would be all kittens and rainbows
– Make StackOverflow Good Again
Nov 15 '18 at 23:09
So... You are creating a DataTable and adding some columns to it (but no data). Then you have a DGV, and you are setting its DataSource to your empty data table, but adding a row to the DGV (even though it has a data source). You need to pick either a) use data binding or b) add stuff manually. In addition: why are you using a data table, why not a collection of strongly typed objects, for example?
– Flydog57
Nov 15 '18 at 23:10
So... You are creating a DataTable and adding some columns to it (but no data). Then you have a DGV, and you are setting its DataSource to your empty data table, but adding a row to the DGV (even though it has a data source). You need to pick either a) use data binding or b) add stuff manually. In addition: why are you using a data table, why not a collection of strongly typed objects, for example?
– Flydog57
Nov 15 '18 at 23:10
I am not adding data to the grid yet, as the column headings will not work. The data will be extracted from a database and placed in the DGV. The code in the 'Answer' does not work on the DGV inside the Form.
– NodeCode
Nov 15 '18 at 23:31
I am not adding data to the grid yet, as the column headings will not work. The data will be extracted from a database and placed in the DGV. The code in the 'Answer' does not work on the DGV inside the Form.
– NodeCode
Nov 15 '18 at 23:31
If you have a database it is not your job to put data in the datatable. Use a DBCommand object or a DataAdapter to fill the table. You are doing everything the hardest way possible
– Make StackOverflow Good Again
Nov 15 '18 at 23:38
If you have a database it is not your job to put data in the datatable. Use a DBCommand object or a DataAdapter to fill the table. You are doing everything the hardest way possible
– Make StackOverflow Good Again
Nov 15 '18 at 23:38
I have inserted the data from my database into lists (that are used in other forms) to make it more robust and work when the connection is down. The data is already inserted to the database and I don't understand how that even came up, nonetheless, the data grid view I have got to work before with roughly 12 lines of code, to insert the data once the headings have been fitted I just need to insert a for loop to iterate through the lists. I just can't get the headings to work, without manually inserting them, I suspect that the DGV in the form has editable locked or maybe I am wrong
– NodeCode
Nov 16 '18 at 0:00
I have inserted the data from my database into lists (that are used in other forms) to make it more robust and work when the connection is down. The data is already inserted to the database and I don't understand how that even came up, nonetheless, the data grid view I have got to work before with roughly 12 lines of code, to insert the data once the headings have been fitted I just need to insert a for loop to iterate through the lists. I just can't get the headings to work, without manually inserting them, I suspect that the DGV in the form has editable locked or maybe I am wrong
– NodeCode
Nov 16 '18 at 0:00
add a comment |
1 Answer
1
active
oldest
votes
you should be adding rows to your datatable then assign that as datasource to datagridview
DataTable Test = new DataTable();
Test.Columns.Add("Text", typeof(string));
Test.Columns.Add("Advice", typeof(string));
Test.Columns.Add("Choice One", typeof(string));
Test.Columns.Add("Choice Two", typeof(string));
Test.Columns.Add("Choice Id (Determines Answer)", typeof(int));
Test.Rows.Add(1, "2x2", "Count with your fingers", "4", "9", 1);;
dgvQuestions.DataSource = Test;
As suggest by Disaffected.. in the comment of your question, you might want to read up on using BindingSource.
I tried this method prior to assigning rows to the DGV and not the data table.I will look at BindingLists, thanks
– NodeCode
Nov 15 '18 at 23:26
@NodeCode, did you say in the comments in the question that your tables have different column names when you retrieve them from the database? it may be binding issue then.
– NoSaidTheCompiler
Nov 16 '18 at 0:04
Currently, the database is not being used, as the headings are not working. The entire form has been acting unexpectedly, I am going to test out the same code on another identical form and check the results. The form seemed to be locked.
– NodeCode
Nov 16 '18 at 0:26
The code works on another form...Can a Form be broken? I don't understand when the entire form is identical
– NodeCode
Nov 16 '18 at 0:29
Is it a new form or form with previously written code? Can you try something really simple and see how that behaves. Like- dgvQuestions.DataSource = new List<string>() {"a","b","c"}; Comment the datatable code for the time being.
– NoSaidTheCompiler
Nov 16 '18 at 0:40
|
show 7 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329085%2fc-sharp-datagridview-rows-are-not-displaying-windows-form-is-broken%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
you should be adding rows to your datatable then assign that as datasource to datagridview
DataTable Test = new DataTable();
Test.Columns.Add("Text", typeof(string));
Test.Columns.Add("Advice", typeof(string));
Test.Columns.Add("Choice One", typeof(string));
Test.Columns.Add("Choice Two", typeof(string));
Test.Columns.Add("Choice Id (Determines Answer)", typeof(int));
Test.Rows.Add(1, "2x2", "Count with your fingers", "4", "9", 1);;
dgvQuestions.DataSource = Test;
As suggest by Disaffected.. in the comment of your question, you might want to read up on using BindingSource.
I tried this method prior to assigning rows to the DGV and not the data table.I will look at BindingLists, thanks
– NodeCode
Nov 15 '18 at 23:26
@NodeCode, did you say in the comments in the question that your tables have different column names when you retrieve them from the database? it may be binding issue then.
– NoSaidTheCompiler
Nov 16 '18 at 0:04
Currently, the database is not being used, as the headings are not working. The entire form has been acting unexpectedly, I am going to test out the same code on another identical form and check the results. The form seemed to be locked.
– NodeCode
Nov 16 '18 at 0:26
The code works on another form...Can a Form be broken? I don't understand when the entire form is identical
– NodeCode
Nov 16 '18 at 0:29
Is it a new form or form with previously written code? Can you try something really simple and see how that behaves. Like- dgvQuestions.DataSource = new List<string>() {"a","b","c"}; Comment the datatable code for the time being.
– NoSaidTheCompiler
Nov 16 '18 at 0:40
|
show 7 more comments
you should be adding rows to your datatable then assign that as datasource to datagridview
DataTable Test = new DataTable();
Test.Columns.Add("Text", typeof(string));
Test.Columns.Add("Advice", typeof(string));
Test.Columns.Add("Choice One", typeof(string));
Test.Columns.Add("Choice Two", typeof(string));
Test.Columns.Add("Choice Id (Determines Answer)", typeof(int));
Test.Rows.Add(1, "2x2", "Count with your fingers", "4", "9", 1);;
dgvQuestions.DataSource = Test;
As suggest by Disaffected.. in the comment of your question, you might want to read up on using BindingSource.
I tried this method prior to assigning rows to the DGV and not the data table.I will look at BindingLists, thanks
– NodeCode
Nov 15 '18 at 23:26
@NodeCode, did you say in the comments in the question that your tables have different column names when you retrieve them from the database? it may be binding issue then.
– NoSaidTheCompiler
Nov 16 '18 at 0:04
Currently, the database is not being used, as the headings are not working. The entire form has been acting unexpectedly, I am going to test out the same code on another identical form and check the results. The form seemed to be locked.
– NodeCode
Nov 16 '18 at 0:26
The code works on another form...Can a Form be broken? I don't understand when the entire form is identical
– NodeCode
Nov 16 '18 at 0:29
Is it a new form or form with previously written code? Can you try something really simple and see how that behaves. Like- dgvQuestions.DataSource = new List<string>() {"a","b","c"}; Comment the datatable code for the time being.
– NoSaidTheCompiler
Nov 16 '18 at 0:40
|
show 7 more comments
you should be adding rows to your datatable then assign that as datasource to datagridview
DataTable Test = new DataTable();
Test.Columns.Add("Text", typeof(string));
Test.Columns.Add("Advice", typeof(string));
Test.Columns.Add("Choice One", typeof(string));
Test.Columns.Add("Choice Two", typeof(string));
Test.Columns.Add("Choice Id (Determines Answer)", typeof(int));
Test.Rows.Add(1, "2x2", "Count with your fingers", "4", "9", 1);;
dgvQuestions.DataSource = Test;
As suggest by Disaffected.. in the comment of your question, you might want to read up on using BindingSource.
you should be adding rows to your datatable then assign that as datasource to datagridview
DataTable Test = new DataTable();
Test.Columns.Add("Text", typeof(string));
Test.Columns.Add("Advice", typeof(string));
Test.Columns.Add("Choice One", typeof(string));
Test.Columns.Add("Choice Two", typeof(string));
Test.Columns.Add("Choice Id (Determines Answer)", typeof(int));
Test.Rows.Add(1, "2x2", "Count with your fingers", "4", "9", 1);;
dgvQuestions.DataSource = Test;
As suggest by Disaffected.. in the comment of your question, you might want to read up on using BindingSource.
edited Nov 15 '18 at 23:14
answered Nov 15 '18 at 23:08
NoSaidTheCompilerNoSaidTheCompiler
1,82521835
1,82521835
I tried this method prior to assigning rows to the DGV and not the data table.I will look at BindingLists, thanks
– NodeCode
Nov 15 '18 at 23:26
@NodeCode, did you say in the comments in the question that your tables have different column names when you retrieve them from the database? it may be binding issue then.
– NoSaidTheCompiler
Nov 16 '18 at 0:04
Currently, the database is not being used, as the headings are not working. The entire form has been acting unexpectedly, I am going to test out the same code on another identical form and check the results. The form seemed to be locked.
– NodeCode
Nov 16 '18 at 0:26
The code works on another form...Can a Form be broken? I don't understand when the entire form is identical
– NodeCode
Nov 16 '18 at 0:29
Is it a new form or form with previously written code? Can you try something really simple and see how that behaves. Like- dgvQuestions.DataSource = new List<string>() {"a","b","c"}; Comment the datatable code for the time being.
– NoSaidTheCompiler
Nov 16 '18 at 0:40
|
show 7 more comments
I tried this method prior to assigning rows to the DGV and not the data table.I will look at BindingLists, thanks
– NodeCode
Nov 15 '18 at 23:26
@NodeCode, did you say in the comments in the question that your tables have different column names when you retrieve them from the database? it may be binding issue then.
– NoSaidTheCompiler
Nov 16 '18 at 0:04
Currently, the database is not being used, as the headings are not working. The entire form has been acting unexpectedly, I am going to test out the same code on another identical form and check the results. The form seemed to be locked.
– NodeCode
Nov 16 '18 at 0:26
The code works on another form...Can a Form be broken? I don't understand when the entire form is identical
– NodeCode
Nov 16 '18 at 0:29
Is it a new form or form with previously written code? Can you try something really simple and see how that behaves. Like- dgvQuestions.DataSource = new List<string>() {"a","b","c"}; Comment the datatable code for the time being.
– NoSaidTheCompiler
Nov 16 '18 at 0:40
I tried this method prior to assigning rows to the DGV and not the data table.I will look at BindingLists, thanks
– NodeCode
Nov 15 '18 at 23:26
I tried this method prior to assigning rows to the DGV and not the data table.I will look at BindingLists, thanks
– NodeCode
Nov 15 '18 at 23:26
@NodeCode, did you say in the comments in the question that your tables have different column names when you retrieve them from the database? it may be binding issue then.
– NoSaidTheCompiler
Nov 16 '18 at 0:04
@NodeCode, did you say in the comments in the question that your tables have different column names when you retrieve them from the database? it may be binding issue then.
– NoSaidTheCompiler
Nov 16 '18 at 0:04
Currently, the database is not being used, as the headings are not working. The entire form has been acting unexpectedly, I am going to test out the same code on another identical form and check the results. The form seemed to be locked.
– NodeCode
Nov 16 '18 at 0:26
Currently, the database is not being used, as the headings are not working. The entire form has been acting unexpectedly, I am going to test out the same code on another identical form and check the results. The form seemed to be locked.
– NodeCode
Nov 16 '18 at 0:26
The code works on another form...Can a Form be broken? I don't understand when the entire form is identical
– NodeCode
Nov 16 '18 at 0:29
The code works on another form...Can a Form be broken? I don't understand when the entire form is identical
– NodeCode
Nov 16 '18 at 0:29
Is it a new form or form with previously written code? Can you try something really simple and see how that behaves. Like- dgvQuestions.DataSource = new List<string>() {"a","b","c"}; Comment the datatable code for the time being.
– NoSaidTheCompiler
Nov 16 '18 at 0:40
Is it a new form or form with previously written code? Can you try something really simple and see how that behaves. Like- dgvQuestions.DataSource = new List<string>() {"a","b","c"}; Comment the datatable code for the time being.
– NoSaidTheCompiler
Nov 16 '18 at 0:40
|
show 7 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329085%2fc-sharp-datagridview-rows-are-not-displaying-windows-form-is-broken%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Given the apparent nature, rather than a DataTable you could use a collection like BindingList and life would be all kittens and rainbows
– Make StackOverflow Good Again
Nov 15 '18 at 23:09
So... You are creating a DataTable and adding some columns to it (but no data). Then you have a DGV, and you are setting its DataSource to your empty data table, but adding a row to the DGV (even though it has a data source). You need to pick either a) use data binding or b) add stuff manually. In addition: why are you using a data table, why not a collection of strongly typed objects, for example?
– Flydog57
Nov 15 '18 at 23:10
I am not adding data to the grid yet, as the column headings will not work. The data will be extracted from a database and placed in the DGV. The code in the 'Answer' does not work on the DGV inside the Form.
– NodeCode
Nov 15 '18 at 23:31
If you have a database it is not your job to put data in the datatable. Use a DBCommand object or a DataAdapter to fill the table. You are doing everything the hardest way possible
– Make StackOverflow Good Again
Nov 15 '18 at 23:38
I have inserted the data from my database into lists (that are used in other forms) to make it more robust and work when the connection is down. The data is already inserted to the database and I don't understand how that even came up, nonetheless, the data grid view I have got to work before with roughly 12 lines of code, to insert the data once the headings have been fitted I just need to insert a for loop to iterate through the lists. I just can't get the headings to work, without manually inserting them, I suspect that the DGV in the form has editable locked or maybe I am wrong
– NodeCode
Nov 16 '18 at 0:00