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

Very confused

Hi, I am evaluating the Syncfusion grid, but I must say, I''m completely confused as to where to even begin. I''ve evaluated about half a dozen other products with not much trouble, but I must say, I don''t even know where to begin. First of all, what is the difference between a GridControl and a GridDataBoundGrid? Is a GridControl only for data that is not bound (it doesn''t seem to have a datasource property)? When should one be used over the other? For the GridDataBoundGrid, how does one go about making columns dropdowns, or have them display buttons. Or hiding some columns (I checked the GridBoundColumns property, but that is empty even after assigning a datasource to the control). After that I would want to know how to programmatically change the style of specific cells (not columns), how to change editor types on the fly, etc. Thanks for any help, Marina

18 Replies

AD Administrator Syncfusion Team May 26, 2004 04:20 PM UTC

Sorry for you confusion. GridControl is a cell oriented grid that can hold its own data or can be used virtually bound to some external data source. GridDataBoundGrid is a column oriented grid that is used bound to some DataSource. Here is a link to a section in the grid''s User Guide that has a short description of each grid control and their primary uses. ms-help://MS.VSCC/Syncfusion.Essential_Suite/Syncfusion.EssentialSuiteUsersGuide/syncfusion.ug.grid/syncfusion.ug.grid/Users%20Guide/Essential%20Grid%20Overview/Major%20Control%20Classes%20Overview.htm In VisStu, if you set you help filter to None, and display the Help Contents, you should see a Syncfusion listing, and under it a UserGuide section. To set styles to columns in a GridDataBoundGrid,you set the GridBoundColumn.StyleInfo property for the particular column. You can do this from the designer by adding GridBoundColumns to the GridBoundColumns collection property. Or, you can do it from code the same way, creating GridBoundColumns and explicitly adding then to the grid.GridBoundColumns collection. Now, if you haven''t explicitly added GridBoundColumns to the grid.GridBoundColumns collection, then you can access the GridBoundColumns internally generated through the grid.Binder.InternalColumns property. So, to set a backcolor a column whose mappingname is "Price", you could use me.Grid.Binder.InternalColums("Price").StyleInfo.BackColor = Color.Red One point to note is if you add your own GridBoundColumns to grid.GridBoundColumns, you must set the GridBoundColumn.MappingName property as this is how the grid maps the column in the DataTable to the GridBoundColumn. This property is case sensitive. In a GridDataBoundGrid, to change the looks of a particular cell, you must use an event like PrepareViewStyleInfo. Here is a link to a KB on it. http://www.syncfusion.com/Support/article.aspx?id=560 You might want to browse the grid''s KB as it has many frequently asked questions answered there.


AD Administrator Syncfusion Team May 26, 2004 05:21 PM UTC

Hi, thanks for the response. You gave an example of how to set a background color - but it looks like that would set it for the entire column? How would this be done on a cell by cell basis, and in what event? Also, is it possible to display a button (or several buttons) on the right hand side of a cell while it is in edit mode? The ''Pushbutton'' style makes the entire cell a button - which isn''t what I want. The cell would have most of it available for typing, with the right hand side having 1 or more buttons (which would need click handler events). Also, is there a way to disable specific cells (not columns)? Thanks, Marina >Sorry for you confusion. > >GridControl is a cell oriented grid that can hold its own data or can be used virtually bound to some external data source. GridDataBoundGrid is a column oriented grid that is used bound to some DataSource. Here is a link to a section in the grid''s User Guide that has a short description of each grid control and their primary uses. >ms-help://MS.VSCC/Syncfusion.Essential_Suite/Syncfusion.EssentialSuiteUsersGuide/syncfusion.ug.grid/syncfusion.ug.grid/Users%20Guide/Essential%20Grid%20Overview/Major%20Control%20Classes%20Overview.htm > >In VisStu, if you set you help filter to None, and display the Help Contents, you should see a Syncfusion listing, and under it a UserGuide section. > > >To set styles to columns in a GridDataBoundGrid,you set the GridBoundColumn.StyleInfo property for the particular column. You can do this from the designer by adding GridBoundColumns to the GridBoundColumns collection property. Or, you can do it from code the same way, creating GridBoundColumns and explicitly adding then to the grid.GridBoundColumns collection. Now, if you haven''t explicitly added GridBoundColumns to the grid.GridBoundColumns collection, then you can access the GridBoundColumns internally generated through the grid.Binder.InternalColumns property. So, to set a backcolor a column whose mappingname is "Price", you could use > >me.Grid.Binder.InternalColums("Price").StyleInfo.BackColor = Color.Red > > >One point to note is if you add your own GridBoundColumns to grid.GridBoundColumns, you must set the GridBoundColumn.MappingName property as this is how the grid maps the column in the DataTable to the GridBoundColumn. This property is case sensitive. > >In a GridDataBoundGrid, to change the looks of a particular cell, you must use an event like PrepareViewStyleInfo. Here is a link to a KB on it. http://www.syncfusion.com/Support/article.aspx?id=560 > >You might want to browse the grid''s KB as it has many frequently asked questions answered there. >


AD Administrator Syncfusion Team May 26, 2004 06:19 PM UTC

>You gave an example of how to set a background color - but it looks like that would set it for the entire column? How would this be done on a cell by cell basis, and in what event? > In a GridDataBoundGrid, to change the looks of a particular cell, you must use an event like PrepareViewStyleInfo. Here is a link to a KB on it. http://www.syncfusion.com/Support/article.aspx?id=560 >Also, is it possible to display a button (or several buttons) on the right hand side of a cell while it is in edit mode? The ''Pushbutton'' style makes the entire cell a button - which isn''t what I want. The cell would have most of it available for typing, with the right hand side having 1 or more buttons (which would need click handler events). > Yes. Take a look at the grid\samples\in depth\cell buttons sample. >Also, is there a way to disable specific cells (not columns)? Yes. Here is a kb on this. http://www.syncfusion.com/Support/article.aspx?id=10351


AD Administrator Syncfusion Team May 27, 2004 10:13 AM UTC

Ok, thanks, I''ll take a look at those. It looks like the help for syncfusion did not get installed with the grids - it is not in VS.NET help at all, so unfortunately I cannot take advantage of that. The example you pointed me to for the buttons is the GridControl - not GridDataBoundGrid (which it sounds like what I need because it needs to be databound). Thanks, Marina > > > >>You gave an example of how to set a background color - but it looks like that would set it for the entire column? How would this be done on a cell by cell basis, and in what event? >> > >In a GridDataBoundGrid, to change the looks of a particular cell, you must use an event like PrepareViewStyleInfo. Here is a link to a KB on it. http://www.syncfusion.com/Support/article.aspx?id=560 > > >>Also, is it possible to display a button (or several buttons) on the right hand side of a cell while it is in edit mode? The ''Pushbutton'' style makes the entire cell a button - which isn''t what I want. The cell would have most of it available for typing, with the right hand side having 1 or more buttons (which would need click handler events). >> >Yes. Take a look at the grid\samples\in depth\cell buttons sample. > >>Also, is there a way to disable specific cells (not columns)? >Yes. Here is a kb on this. http://www.syncfusion.com/Support/article.aspx?id=10351


AD Administrator Syncfusion Team May 27, 2004 10:27 AM UTC

When looking for our help in Vis Stu, make sure you set the Filtered by: to (no filter).


AD Administrator Syncfusion Team May 27, 2004 10:46 AM UTC

Yep, I did that. Nothing there - even went to contents, no Syncfusion top level item. So is it possible to have a button (or buttons) appear on the side of a cell in a GDBG and handle the button click event? If so, how? Thanks, Marina >When looking for our help in Vis Stu, make sure you set the Filtered by: to (no filter).


AD Administrator Syncfusion Team May 27, 2004 12:04 PM UTC

Yes, you can have a button in a cell in a GridDataBoundGrid. You can use the same control that is part of the grid\samples\In depth]cellbuttons sample. Just add the ellipsis.cs (or .vb) to your project, and register the control to be able to use it. (You will have to change the namespace in this line iconPainter = New GridIconPaint("TextPlusButton.", GetType(EllipsisCellButton).Assembly) to match the one you are using, and also make sure the bitmap has been added to your project as a embedded resource.) Here is a sample. TextPlusButton_9126.zip


AD Administrator Syncfusion Team May 27, 2004 12:14 PM UTC

Ok thanks. But there is no built in way to get this behavior (such as there is by setting the CellType property)? Also, this would have to be extended manually to support multiple buttons in a cell, etc? I am just trying to figure out what it would take to support this sort of behavior. Thanks for all your help so far. Marina >Yes, you can have a button in a cell in a GridDataBoundGrid. You can use the same control that is part of the grid\samples\In depth]cellbuttons sample. > >Just add the ellipsis.cs (or .vb) to your project, and register the control to be able to use it. (You will have to change the namespace in this line > >iconPainter = New GridIconPaint("TextPlusButton.", GetType(EllipsisCellButton).Assembly) > to match the one you are using, and also make sure the bitmap has been added to your project as a embedded resource.) > >Here is a sample. > >TextPlusButton_9126.zip > >


AD Administrator Syncfusion Team May 27, 2004 12:20 PM UTC

You will have to add a custom cell type to get these buttons. Yes, you can put multiple buttons in a cell (but you do have to use a custom cell type do it). In the same CellButtons sample, there is a cell control with 3 buttons in the cell....


AD Administrator Syncfusion Team May 27, 2004 12:34 PM UTC

Ok, gotcha, thanks. Next question: I am trying to get a basic databinding going. I set the datasource, added 3 columns, set their MappingName properties. A couple of them have cell types other then textbox - but one has a textbox type. All of the cells are showing up as blank - although there is a row for every row in the data source. Also, when I select a value from the dropdown that is a cell type of one of the columns - as soon as I navigate away from the cell, the cell is blanked out. Same goes if I type something into a cell that is a textbox cell type. What am I doing wrong? Is there something else I needed to set? Thanks, Marina >You will have to add a custom cell type to get these buttons. > >Yes, you can put multiple buttons in a cell (but you do have to use a custom cell type do it). In the same CellButtons sample, there is a cell control with 3 buttons in the cell....


AD Administrator Syncfusion Team May 27, 2004 01:31 PM UTC

Most times, empty grids mean that the mapping names (grid.GridBoundColumns[i].MappingName) does not match a DataColumn.ColumnName for a column in the DataTable. These items are case senstive and must match exactly. Another reason for empty grid is not calling DataAdapter.Fill to load you dataset, but you said you are datarows so this is not likely teh case. If you cannot spot something, if you will post a sample, we can try to post the problem here.


AD Administrator Syncfusion Team May 27, 2004 02:52 PM UTC

Hi, the names should match exactly since I picked the column from the dropdown at design time. I am adding the rows manually by hand (in a large loop) - so this datatable definitely has rows with real data. I am including code, that just has the columns be regular text editor columns - nothing fancy. The code runs, with all the rows - but they are all blank. Thanks, Marina >Most times, empty grids mean that the mapping names (grid.GridBoundColumns[i].MappingName) does not match a DataColumn.ColumnName for a column in the DataTable. These items are case senstive and must match exactly. > >Another reason for empty grid is not calling DataAdapter.Fill to load you dataset, but you said you are datarows so this is not likely teh case. > >If you cannot spot something, if you will post a sample, we can try to post the problem here. GridTest_2823.zip


AD Administrator Syncfusion Team May 27, 2004 03:02 PM UTC

Place this at the end of your Form_Load. Me.GridDataBoundGrid1.Binder.InitializeColumns()


AD Administrator Syncfusion Team May 27, 2004 03:39 PM UTC

Thanks, that did it. Is there a reason this doesn''t happen automatically? It''s not at all obvious that an extra call needs to be made (usually the binding just sort of happens). Also, I am trying to place some validation logic, to turn fields different colors depending on the condition. The PrepareViewStyleInfo event you suggested, fires constantly - when mousing over a field, loading a field - just hundreds of times. I tries handling another event, and changing the current cell''s color through the CurrentCell property of the grid. However, I could not find a BackColor, Style, or any other property that would give me access to the current''s cell''s look and feel properties. Where is that? Also, is there a way to retrieve the value of a given cell in a given row? I really appreciate all the time you''ve spent helping me, Marina >Place this at the end of your Form_Load. > > Me.GridDataBoundGrid1.Binder.InitializeColumns() > >


AD Administrator Syncfusion Team May 27, 2004 03:57 PM UTC

If you had set the DataSource in formload, I do not think you would have needed the extra call. But because you set the datasource in the designer, and because of the setting for the grid.UseListChangedEvent property set by default, you did need teh extra call. If you want to conditionally set the backcolor of individual cells in a GridDataBoundGrid, then you will have to use PrepareViewStyleInfo. That is the way to do it. To get the value of a particular cell, you use Dim val as object = me.grid(rowIndex, colIndex).CellValue


AD Administrator Syncfusion Team May 27, 2004 04:36 PM UTC

Thanks for your response. But PrepareViewStyleInfo fires all the time. Wouldn''t it be wasteful to constantly be changing the color of a cell to something - when it''s just a user mousing over? I mean, we are talking about a potentially expensive function call, just to figure out what needs to happen to that cell (lock it, change it''s color, etc) - I don''t think that is something that I would want called hundreds of times, when all those times, nothing happened at all that would even possibly mean that anything about the cell has to change. Would only want this to happen when a cell value changed, possibly in a few other instances - but not when the user is just moving the mouse around over the grid. Is there any other way other then PrepareViewStyleInfo? I appreciate your quick responses to my neverending questions :). Thanks, Marina >If you had set the DataSource in formload, I do not think you would have needed the extra call. But because you set the datasource in the designer, and because of the setting for the grid.UseListChangedEvent property set by default, you did need teh extra call. > >If you want to conditionally set the backcolor of individual cells in a GridDataBoundGrid, then you will have to use PrepareViewStyleInfo. That is the way to do it. > >To get the value of a particular cell, you use > >Dim val as object = me.grid(rowIndex, colIndex).CellValue >


AD Administrator Syncfusion Team May 27, 2004 05:20 PM UTC

>>Is there any other way other then PrepareViewStyleInfo? No, not in a GridDataBoundGrid. (In a GridControl, yes.) Try it, I think you will see it works well normally. If the things you have to do to determine what colors need to be assigned are ''expensive'', then you can cache these values and retireve them quickly from your cache. But try things out directly in PrepareViewStyleInfo first. (Don''t put any debug output in the routine though because that is usually 1000+ times slower than what you might do to decide what the colors should be.)


AD Administrator Syncfusion Team May 27, 2004 05:43 PM UTC

Ok, thanks for all the info, I will keep that in mind. >>>Is there any other way other then PrepareViewStyleInfo? > >No, not in a GridDataBoundGrid. (In a GridControl, yes.) Try it, I think you will see it works well normally. > >If the things you have to do to determine what colors need to be assigned are ''expensive'', then you can cache these values and retireve them quickly from your cache. But try things out directly in PrepareViewStyleInfo first. (Don''t put any debug output in the routine though because that is usually 1000+ times slower than what you might do to decide what the colors should be.)

Loader.
Live Chat Icon For mobile
Up arrow icon