We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Radio Buttons in GDBG

Hi, Which event is best to set a cell type for each cell of a column to radio button? I have a GDBG, I want to display radio buttons in each cell of a column and radio buttons are selected based on the data value in data table. I need to display four options/choice list for each cell. Do I have to do this for each cell or can I somehow assign choice list or cell type for a column itself? How do I make appropriate radio button selected based on data value in column?

11 Replies

AD Administrator Syncfusion Team April 14, 2005 10:52 PM UTC

If all the ChoiceList items are the same, then use the grid.GridBoundColumns["ColumnName"].StyleInfo (or grid.Binder.InternalColumns["ColumnName"].StyleInfo if you have not explicitly added GridBoundColumns to your grid) to set the style.ChoiceList and style.CellType for the column. Then if you DataBase feeds integer 0, 1, 2, 3 as values fro the column, then that is all you should have to do.


AD Administrator Syncfusion Team April 15, 2005 12:39 AM UTC

Hi, I am really looking forward to get the answer this question. I am using a GDBG and for one of the column cell type is defined a radio button. The source for this column is a string column in a data table, which represent the data in the following manner. W--- Weekly M—Monthly Y—Yearly Now we have three radio buttons on each cell and based on the column value appropriate radio button should be selected. Like OWeekly OMonthly OYearly Now where do we specify the mapping of values and radio buttons? No matter what I send from the database no radio button is selected. Following is the code that I am using. this.gridBoundColumn12.HeaderText = "Access"; this.gridBoundColumn12.MappingName = "access_flag"; this.gridBoundColumn12.StyleInfo.CellType = "RadioButton"; this.gridBoundColumn12.StyleInfo.CellValueType = typeof(string); this.gridBoundColumn12.StyleInfo.TextAlign = Syncfusion.Windows.Forms.Grid.GridTextAlign.Right; StringCollection sc = new StringCollection(); sc.AddRange(new String[]{ “Weekly”, "Monthly", "Yearly"}); this.gridBoundColumn12.StyleInfo.ChoiceList = sc; Please do reply! Thanks


AD Administrator Syncfusion Team April 15, 2005 01:35 AM UTC

The radiobutton cell type expects its values to be 0, 1, 2 not W, M, Y. So, in order to get this to work, you will need to handle grid.Model.QueryCellInfo. There, when e.RowIndex and e.ColIndex point to your column, change e.Style.CellValueType from typeof(string) to typeof(int). Also, switch the e.Style.CellVale from W, M, Y to 0,1,2. You will also have to handl grid.Mdoel.SaveCellInfo and switch things back. Here is a sample. http://www.syncfusion.com/Support/user/uploads/GDBG_RadioButton_f5fa94a0.zip


AD Administrator Syncfusion Team April 15, 2005 02:07 PM UTC

Hi, I havn’t tried the suggested coding yet. AS soon as i am at work i will try it. Let me ask something. I have attached a typed dataset to GDBG at the Design time to do some formatting. Now at the run time I assign similer datatable to my grid. I tried to feed 0 or 1 from the database but it didn’t work. What could be the reason? May be because of typed dataset? Because in typed dataset I had declared that column as string. Should I try with new typed datset? Now about your suggestion. Q#1 Why do we need to change CellValueType from typeof(string) to typeof(int) in grid.Model.QueryCellInfo event? From database I was feeding ‘string’ and I defined as this.gridBoundColumn12.StyleInfo.CellValueType = typeof(string); Now by default it takes 0 or 1, so what if I defined as or can I adefined as this.gridBoundColumn12.StyleInfo.CellValueType = typeof(int); Q#2 where exactly grid.Model.SaveCellInfor get triggered? Why doI need to do this? Pleased help.


AD Administrator Syncfusion Team April 15, 2005 02:08 PM UTC

Hi, I havn’t tried the suggested coding yet. AS soon as i am at work i will try it. Let me ask something. I have attached a typed dataset to GDBG at the Design time to do some formatting. Now at the run time I assign similer datatable to my grid. I tried to feed 0 or 1 from the database but it didn’t work. What could be the reason? May be because of typed dataset? Because in typed dataset I had declared that column as string. Should I try with new typed datset? Now about your suggestion. Q#1 Why do we need to change CellValueType from typeof(string) to typeof(int) in grid.Model.QueryCellInfo event? From database I was feeding ‘string’ and I defined as this.gridBoundColumn12.StyleInfo.CellValueType = typeof(string); Now by default it takes 0 or 1, so what if I defined as or can I adefined as this.gridBoundColumn12.StyleInfo.CellValueType = typeof(int); Q#2 where exactly grid.Model.SaveCellInfor get triggered? Why doI need to do this? Pleased help.


AD Administrator Syncfusion Team April 15, 2005 02:15 PM UTC

If you can change your dataset to use integer 0, 1, 2 instead of string W, M,Y, that will be the simplest thing to do. Q1- The RadioButton expects an integer. Your datasource is providing a string. The radio button does not work with a string. That is why you need to use QueryCellInfo. To swap your string W, M, Y into an integer 0, 1, 2. Q2 - You need to handle SaveCellInfo to change the integer 0,1,2 that the RadioButton cell uses into the W, M, Y that your datasource needs. Now if you change your datasource to use 0, 1, 2, you would not need to use these events.


AD Administrator Syncfusion Team April 15, 2005 03:41 PM UTC

thansk, Q#1 Do i have to change my typed dataset too? i hope using typed dataset is not casuing any problem because i am using this for just formatting. at the run time i assign a new datatable (which is 100% similer to typed datase) Q#2 let''s say i change the dataset, them what would be the cellvaluetype e.Style.CellValueType = typeof(int); OR e.Style.CellValueType = typeof(string); Pleas edo reply! >If you can change your dataset to use integer 0, 1, 2 instead of string W, M,Y, that will be the simplest thing to do. > >Q1- The RadioButton expects an integer. Your datasource is providing a string. The radio button does not work with a string. That is why you need to use QueryCellInfo. To swap your string W, M, Y into an integer 0, 1, 2. > >Q2 - You need to handle SaveCellInfo to change the integer 0,1,2 that the RadioButton cell uses into the W, M, Y that your datasource needs. > >Now if you change your datasource to use 0, 1, 2, you would not need to use these events.


AD Administrator Syncfusion Team April 15, 2005 03:58 PM UTC

My code // // gridBoundColumn12 // this.gridBoundColumn12.HeaderText = "Access"; this.gridBoundColumn12.MappingName = "access_flag"; this.gridBoundColumn12.StyleInfo.CellType = "RadioButton"; this.gridBoundColumn12.StyleInfo.CellValue = 0; this.gridBoundColumn12.StyleInfo.CellValueType = typeof(int); this.gridBoundColumn12.StyleInfo.Text = "0"; this.gridBoundColumn12.StyleInfo.TextAlign = Syncfusion.Windows.Forms.Grid.GridTextAlign.Right; My typed dataset (assigned to GDBG) Runtime assignment of datable to grid private void DisplaySelcetedCompanyList(DataTable dtCompany) { this.gdbdSelectedCompany.BeginUpdate(); this.gdbdSelectedCompany.Model.ColWidths[0] = 0; this.gdbdSelectedCompany.Model.ColWidths[1] = 0; this.gdbdSelectedCompany.Model.ColWidths[2] = 80; this.gdbdSelectedCompany.Model.ColWidths[3] = 150; DataView dvCompnaySelected = dtCompany.DefaultView; this.gdbdSelectedCompany.DataSource = dvCompnaySelected; this.gdbdSelectedCompany.EndUpdate(); } datatable is being filed with select uc.company_no, c.company_id, 1 // this is the last radibutton column from user_company uc, company c where uc.user_no = @p_user_no and c.company_no= uc.company_no please help me.


AD Administrator Syncfusion Team April 15, 2005 04:40 PM UTC

Your typed dataset did not display so I cannot see if it has a integer column instead of teh string column you initially described. If you can upload a sample project that you want to see working, I can try to get it working. If it uses a database, then try using an mdb file as your datasource and include it with your sample project.


AD Administrator Syncfusion Team April 15, 2005 05:45 PM UTC

Please find the attached sample. you even don''t need the database. it is not working even with a on fly datatable. I have a typed dataset attached initally then i assign a new datatable at the run time. please help me. I would really appreciate if you could make this working. sample_9600.zip


AD Administrator Syncfusion Team April 15, 2005 08:31 PM UTC

Thanks clay. I got the answer from Jay N. >Please find the attached sample. > >you even don''t need the database. it is not working even with a on fly datatable. > > >I have a typed dataset attached initally then i assign a new datatable at the run time. > >please help me. > >I would really appreciate if you could make this working. > > > >sample_9600.zip > >

Loader.
Live Chat Icon For mobile
Up arrow icon