|
Look i made a class TaskBar
class TaskBar{
}
it has some set of properties
then in a winfdow form i made a datagridview as db1;
there i made a list of type TaskBar;
List<TaskBar> m_Tasks = new m_Tasks<TaskBar>();
then i have a function which is called a a button click event there i wrote this code
here i insert some data in the m_Tasks List ;
db1.DataSource = m_Tasks; db1.AutoGenerateColumns = true; db1.Invalidate();
now tell me why the ____ the data grid is not getting populated by the data. tell me what should i do.
|
| connect2vishal Thursday, April 16, 2009 1:14 PM |
Form dynamic list that should update the databindings you can better use BindingList<T> instead of List<T>. BindingList<T> will trigger updates when you add items to this list. - Marked As Answer byLinda LiuMSFT, ModeratorTuesday, April 21, 2009 6:10 AM
-
|
| boothwine Thursday, April 16, 2009 2:20 PM |
One point: you should not add items from another thread. Add only items from UI thread else the DataGridView will have issues...
- Marked As Answer byLinda LiuMSFT, ModeratorTuesday, April 21, 2009 6:10 AM
-
|
| boothwine Thursday, April 16, 2009 2:31 PM |
public class stud
{
public string name { get; set; }
}
private void Form1_Load(object sender, EventArgs e)
{
List<stud> s = new List<stud>();
stud ss = new stud();
ss.name = "a";
s.Add(ss);
ss = new stud();
ss.name = "b";
s.Add(ss);
dataGridView1.DataSource = s;
dataGridView1.AutoGenerateColumns = true;
}
/// Tried the above code; its working perfect
Thanks,
A.m.a.L |
[Remember to click "mark as answered" when you get a correct reply to your question] |
| A.m.a.L - aditi.com - Think Product Thursday, April 16, 2009 1:22 PM |
but in my case i got some success but not as whole gimme ur email id i send u the code plz..........
i need serious help... assap |
| connect2vishal Thursday, April 16, 2009 1:47 PM |
actually in my case when i try to add somthing more dynamically it doesnt show the effect.......... means row count is not increasing.................. :( |
| connect2vishal Thursday, April 16, 2009 1:49 PM |
Error1'NewsReaderLook.Form3.stud.name.get' must declare a body because it is not marked abstract or externF:\GanttChartResearch\117 march 2009\treegridview\TreeGridView Test App\Form3.cs4834News Reader Look
this is what i am getting |
| connect2vishal Thursday, April 16, 2009 1:56 PM |
Are you using dataGridView or TreeGridView? Is this TreeGridView this one If so than you can't use data bindings. (these are probably not aware of nodes and sub-nodes) |
| boothwine Thursday, April 16, 2009 2:05 PM |
no right now this is data grid view............
please check my code plz.............. thanx....... |
| connect2vishal Thursday, April 16, 2009 2:12 PM |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;
namespace NewsReaderLook { public partial class Form3 : Form { List<stud> s; public stud ss; public Form3() { InitializeComponent(); }
private void Form3_Load(object sender, EventArgs e) { s = new List<stud>();
ss = new stud(); ss.Name = "a"; s.Add(ss);
ss = new stud(); ss.Name = "b"; s.Add(ss);
dataGridView1.DataSource = s; dataGridView1.AutoGenerateColumns = true;
}
private void button1_Click(object sender, EventArgs e) { ss = new stud(); ss.Name = "c"; s.Add(ss);
dataGridView1.Invalidate(); }
public class stud { public string name = ""; public string Name { get { return name; } set { name = value; } } }
} } |
| connect2vishal Thursday, April 16, 2009 2:13 PM |
Form dynamic list that should update the databindings you can better use BindingList<T> instead of List<T>. BindingList<T> will trigger updates when you add items to this list. - Marked As Answer byLinda LiuMSFT, ModeratorTuesday, April 21, 2009 6:10 AM
-
|
| boothwine Thursday, April 16, 2009 2:20 PM |
thnax with some issues its a bit working......... :) |
| connect2vishal Thursday, April 16, 2009 2:26 PM |
One point: you should not add items from another thread. Add only items from UI thread else the DataGridView will have issues...
- Marked As Answer byLinda LiuMSFT, ModeratorTuesday, April 21, 2009 6:10 AM
-
|
| boothwine Thursday, April 16, 2009 2:31 PM |