Hello All,

I have a C1TrueDBGrid on my form it was working fine but when i added a new view i.e. on button click grid's datasource changed and display new values but the problem is that on this click i don't know why the checkbox column of my grid widens up... I have done nothing just pasted the previous code and changed the query please help me :(

Thanks in advance

you should have changed the width somewhere or may be you are accessing columns somewhere in the code please paste your code so that we will be able to find the error

Best would be to give us the code. Then we can point you into the righ direction...

Thanks for your reply here is the code this is the code it is written in a function and every time i only call this function without changing it can you please tell me what is wrong with this code

dataSet1.Tables[0].Columns.Add("check_box", typeof(bool));
            dataSet1.Tables[0].Columns["check_box"].SetOrdinal(0);
                 
            tbLoad.DataSource = dataSet1.Tables[0];
//formatting of columns
             
         if (dataSet1.Tables[0].TableName == "users")
        {
              tbLoad.Splits[0].DisplayColumns["password"].Visible = false;
               tbLoad.Splits[0].DisplayColumns["user_id"].Visible = false;
            }
         
            /*---------------------------------------------------------*/
            /*               CheckBOx Column                          */
            /*-------------------------------------------------------*/
           
            C1.Win.C1TrueDBGrid.ValueItemCollection check1 = tbLoad.Columns["Check_box"].ValueItems.Values;
            tbLoad.Columns["Check_box"].ValueItems.Translate = true;
           tbLoad.Columns["Check_box"].ValueItems.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox;
            check1.Add(new C1.Win.C1TrueDBGrid.ValueItem("0", false));
            check1.Add(new C1.Win.C1TrueDBGrid.ValueItem("1", true));

           //formatting of checkbox column

what are the table names you are using and please mention number of times you call this function and each time please mention the table name also.
like first call=tabl_1, 2nd call=tabl_2 and so on....

ok first_call=table_name1(columnset1), 2nd_call=table_name2, 3rd_call=table_name3
, 2nd_call=table_name2, 3rd_call=table_name1(columnset2)

Replace these lines

if (dataSet1.Tables[0].TableName == "users")
        {
              tbLoad.Splits[0].DisplayColumns["password"].Visible = false;
               tbLoad.Splits[0].DisplayColumns["user_id"].Visible = false;
            }

with

for (int k = 0; k < tbLoad.Columns.Count; k++)
            {
if (tbLoad.Columns[k].Caption.ToUpper() == "caption of password column" || tbLoad.Columns[k].Caption.ToUpper() == "caption of user_id column")
tbLoad.Splits[0].DisplayColumns[k].Visible = false;
            }

it will solve your problem. This error is coming because you are calling this function for same table with different columns

commented: Worked for me :) +1

thanks abellazm it really worked thanks again

Hi,
I am new to winforms i m using C1TrueDBGrid if i assign datasource to grid i am able see columns else i can't add columns at Design time ..?

Any replies will be accepted...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.