Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CheckBox In DataGridView - AGAIN
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01441152
Message ID:
01441255
Vues:
39
You're not going to beleive this. I need a vacation. Really I do.

I had the grid's ReadOnly set to true in the prop sheet.

Someone slap me.




>>Ok everyone, I'm REALLY peeved at this point. I have no clue why this isn't working. I have spent anothr day Googling for answers and found nothing. This CAN'T be that hard to do. So what am I doing wrong????
>>
>>Here's my method. It adds a new row to the data data. If the table does not exist, it is first created. Notice that there is a bool column. It shows up in the DataGridView control as a checkbox - it just doesn't check. HELP!!
>>
>>
>>private void _AddRow()
>>{
>>    if (dsGrid.Tables.Count == 0)
>>    {
>>        DataTable table = new DataTable();
>>        table.Columns.Add("ColumnId", typeof(int));
>>        table.Columns.Add("QueryId", typeof(int));
>>        table.Columns.Add("TableId", typeof(int));
>>        table.Columns.Add("TableName", typeof(string));
>>        table.Columns.Add("ApexColumnName", typeof(string));
>>        table.Columns.Add("Expression", typeof(string));
>>        table.Columns.Add("GroupBy", typeof(bool));         // The checkbox column
>>
>>        dsGrid.Tables.Add(table);
>>
>>        grdData.DataMember = dsGrid.Tables[0].TableName;
>>        grdData.DataSource = dsGrid.Tables[0];
>>    }
>>
>>    DataRow NewRow = dsGrid.Tables[0].NewRow();
>>    NewRow["QueryId"] = _QueryId;
>>    dsGrid.Tables[0].Rows.Add(NewRow);
>>}
>>
>Just tried this. Firstly is looks as if a bool value will default to using a DataGridViewCheckBox automatically..
>Anyway your code as posted works fine for me from the Form OnLoad:
protected override void OnLoad(EventArgs e)
>        {
>            DataSet dsGrid = new DataSet();
>            if (dsGrid.Tables.Count == 0)
>            {
>                DataTable table = new DataTable();
>                table.Columns.Add("ColumnId", typeof(int));
>                table.Columns.Add("QueryId", typeof(int));
>                table.Columns.Add("TableId", typeof(int));
>                table.Columns.Add("TableName", typeof(string));
>                table.Columns.Add("ApexColumnName", typeof(string));
>                table.Columns.Add("Expression", typeof(string));
>                table.Columns.Add("GroupBy", typeof(bool));         // The checkbox column
>
>                dsGrid.Tables.Add(table);
>
>                grdData.DataMember = dsGrid.Tables[0].TableName;
>                grdData.DataSource = dsGrid.Tables[0];
>            }
>
>            DataRow NewRow = dsGrid.Tables[0].NewRow();
>            NewRow["QueryId"] = 5;
>            dsGrid.Tables[0].Rows.Add(NewRow);
>        }
(only change is creating a DataSet and changing the "QueryId" to a concrete value.) Only action in the designer was dropping a DataGridView on the Form and setting the Name. Does this work for you?
>
>Where is your _AddRow() method called from?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform