eagle275
2020-05-29T08:55:43Z
First of all - I downloaded the demo to test your iGrid and I like how its faster than the DataTableGrid - but I have some problems...

We want to use iGrid in an already existing app - and replace DataTableGrid - but this means it should offer the same "look and feel" and here along come my problems

I used

            dGrid.SelectionMode = iGSelectionMode.MultiExtended;
            dGrid.RowMode = true;
            
            dGrid.Header.Appearance = iGControlPaintAppearance.StyleFlat;

            dGrid.Header.DrawSystem = false;
            iGPenStyle hStyle=new iGPenStyle();
            hStyle.Color=dGrid.Header.BackColor;

            dGrid.Header.VGridLinesStyle = hStyle;
                
            dGrid.Header.Height = 40;
            dGrid.Header.HotTracking = false;


to make it look similar to the "old" style
but: HotTracking = false doesn't do what its supposed to do - disable moving around of columns ...
so here are a set of my questions :
1) How do I set the columns "fix" - not movable
2) How do I disable column resizing with the mouse
3) if possible I need to learn the iGrid-commands to achieve the following in similar fashion for iGrid

   dataGridViewTable.RowsDefaultCellStyle = dataGridViewTable.DefaultCellStyle;

   if (Checkboxes)
   {
      dataGridViewTable.RowsDefaultCellStyle.SelectionBackColor = Color.Transparent;
      dataGridViewTable.RowsDefaultCellStyle.SelectionForeColor = Color.Transparent;
   }

   dataGridViewTable.EnableHeadersVisualStyles = false;
   dataGridViewTable.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
   dataGridViewTable.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
   dataGridViewTable.ColumnHeadersHeight = 40;

Igor/10Tec
2020-05-29T15:18:34Z
First of all, thank you for your interest in our product.

If you downloaded and installed the full iGrid demo, you should have the iGrid manual in the PDF format. It's the first place you can use to find your answers in because it describes all basic concepts of iGrid, including the questions you asked. But no problems if you ask us. And we can even help you with building your app if you send us your source code. It will be much easier to help you and suggest something when we have the sources.

If you want to make the header area flat, we recommend that you turn off visual styles with the UseXPStyles property like that:
dGrid.Header.UseXPStyles = false;
dGrid.Header.Appearance = iGControlPaintAppearance.StyleFlat;

This is the preferred way to do what you need instead of turning system drawing totally off with the DrawSystem property.

The HotTracking property of the Header object disables the hot-tracking effect, i.e. the effect when the column header under the mouse pointer is highlighted. This is not the same as column moving/resizing. To disable column moving and resizing, use the AllowMoving/AllowSizing properties of the column object (iGCol). These features can be configured independently for every column, but if you need this for all columns, the best way to do this is to specify these properties in the default column object before you create your columns:
iGrid1.DefaultCol.AllowMoving = false;
iGrid1.DefaultCol.AllowSizing = false;


Implement this in your solution first, and let's consider all your further questions one-by-one.
Igor/10Tec
2020-05-29T16:46:39Z
Can you also post a picture of the grid you want to re-build with iGrid to better understand your task?
eagle275
2020-06-05T08:09:22Z
thanks for your suggestions - I already put in the

iGrid1.DefaultCol.AllowMoving = false;
iGrid1.DefaultCol.AllowSizing = false;

commands - but they get ignored because I fill in data AFTER initially displaying the igrid -
but I detected a severe problem ...

I applied similar functionality after filling in the data - but "it behaves very strangely" ..

mainly I inserted a loop going over all iGrid.Cols to

                        dGrid.Cols[i].AllowMoving = false;
                        dGrid.Cols[i].AllowSizing = true;
                        dGrid.Cols[i].AutoWidth(false);


If I set AllowSizing to false - the iGrid displays a horizontal scroll bar .. but the columns are too narrow and I cant change them (forbid resizing) but when I set AllowSizing to false - the iGrid only takes the width alloted by the initial .Size property .. which is nonsense .. I have 15+ columns .. and columnsizing would allow the user of the program to focus on the columns he is interested in - but either I'm dumb OR iGrid forces me to choose one of 2

  • allow Column Resizing but make the display unreasonable by not displaying a scrollbar - so other columns become rediculously narrow
  • no column Resizing - display scrollbar - but display is still rediculous - because all columns are very narrow and the user cant resize the ones he wants to see


So my question is - how do I allow Column-Resizing AND allow the iGrid to stretch in horizontal size, once the user makes a group of columns broader?

primarily I want similar functionality to datagridviewtable that holds much broader content than the viewport showed via size property (and scrollbars to let you view the other content)
Igor/10Tec
2020-06-05T15:05:43Z
Do you want to say that iGrid does not adjust the column width when you call the AutoWidth() method if the AllowSizing property for the column is set to False?

Can you send us a sample demonstrating the problem?
eagle275
2020-06-09T07:42:24Z
certainly not in the way I am used from datatablegridview ...

the datatablegridview would make the column big enough to fit the longest contained element.

For iGrid that does not happen .. for some reason iGrid tries its hardest to fit everything in the size-dimensions I set on creation - mainly the width .. for the vertical scroll bar is applied when there are more rows than fit on the height of the iGrid - but horizontally NOT - which becomes even more annoying when dragging on column borders to read the content - instead of moving the (right) columns more to the right to accommodate, they shrink to be unreadable (1...2 characters or even less)

I'm basically experimenting with the iGrid "switches" I find by using the help and syntax completion - but they tend to behave surprising

I'll try to compile a sample showing my problems

- code sample works from Visual Studio 2019 - it will create a usable usercontrol which will finally be integrated as DLL into the target environment using Wonderware inTouch - hence it has a set of property methods
after setting database + credentials , correct sqlquery - just click on refresh bottom left
Igor/10Tec
2020-06-09T15:32:49Z
First, don't publish the iGrid source code on the forum, please.

Second, I launched your solution, but I do not see how I can load some data into the grid to see the problems you are describing. The startup project is a UserControl, and VS launches the test environment for it. Even I click the button to connect to the SQL db, I can't do that because I do not have your database.

Can you show your problem in a simple WinForms app with one form and one iGrid populated manually? I think 2-3 rows of data will be enough to show your problems.
eagle275
2020-06-11T08:25:13Z
sry about the sources .. I overworked my code to simply display some columns of random characters

upon displaying the empty control - click on refresh bottom left

And it clearly shows my problem(s)

the code generates 20 columns - that don't fit the viewport - but instead of enabling the horizontal scrollbar despite giving the explicit command

dGrid.HScrollbar.Enabled=true;


instead iGrid displays the columns shrunken - but only when I give dGrid.Cols[i].AutoWidth(false)

if I use dGrid.Cols[i].AutoWidth() or AutoWidth(true) - some columns are displayed on top of each other - why not use the Scrollbar and display them next to each other - and according to autowidth - as broad as the data are

  test.zip (77kb) downloaded 5 time(s).
abraXus
2020-06-12T05:28:12Z
I have a somewhat related question, so instead of creating a new topic, I will append my question to this one. If you would prefer I create another topic, I can do that instead.

In my application, I want the headers to be able to autosize the height and width programmatically, and for the most part, this works fine for me. However, i do not want the user to be able to change the widths afterwards. If I disable the ability for the user to resize the columns, then the autosize function doesn't do what it's supposed to either.

I would think the autowidth method would ignore the allowsizing setting, since it is done programmatically instead of by the user, but it seems that is not the case. But since I am still in the process of learning how to use the features, maybe I am missing something.

The only other thing I can think of would be to enable resizing, run the autowidth method, and then disable the sizing again. I did actually try to get that to work, but did not have much luck. I didn't try all that hard tho, so maybe I can try a bit harder again if you can confirm that this technique should work.

Again, apologies if this should be its own topic.

eagle275
2020-06-12T08:21:41Z
@abraXus - the described behavior is indeed intended - according to the help "Notice that the method adjusts only the width of visible columns with resizing allowed (see the AllowSizing property)

so you have to allow resizing if you want to adjust the widths using your way ...


As for my problem .. I came a bit further ...

turns out AutoResizeCols is the culprit (when set to true) - iGrid always tries its hardest to fit all columns in the viewport

after setting the MinWidth property to a reasonable value my grid now does what I want ...


private iGAutoWidthColMode ColumnMode=iGAutoWidthColMode.HeaderAndCells; // general autowidth-setting .. adjust to header and cell-text width
...
dGrid.AutoResizeCols=false; // dont fit everything into viewport
for(int i=0;i<dGrid.Cols.Count;i++) {
.....
   dGrid.Cols[i],AllowMoving(false); // columns remain in order
   dGrid.Cols[i].AllowSizing(true); // user and program can change width of columns 
   dGrid.Cols[i].MinWidth=dGrid.Cols[i].Width; // minwidth is width of originally created column
   dGrid.Cols[i].AutoWidth(true);            // Automatic width according to AutoWidthColMode - which is set to ColumnMode defined above
}
dGrid.HScrollBar.Enabled=true;
dGrid.HScrollBar.Visibilty=iGScrollBarVisibility.Always;  // enable horizontal scrollbar and force its display
Igor/10Tec
2020-06-12T11:52:15Z
eagle275, I'm glad you found the reason why column sizing does not work as you expected. Yes, really, if the auto-resize-cols mode is on, it turns off many column sizing features because column widths must be set automatically. BTW, the AllowSizing setting is used in this process too.

eagle275 & abraxUs: Do you think it would be better not to check the AllowSizing setting if we call the AutoWidth() method for a column or the whole column collection? As I remember (but I may be wrong), there were cases when developers wanted to exclude some columns from processing when they called Cols.AutoWidth(). That's why we implemented the behavior we have now. But if you think it's more natural not to check this status in AutoWidth(), we could think about implementing this change in the forthcoming release of iGrid.NET X. Let me also ask other developers.

Igor/10Tec
2020-06-12T11:58:59Z
eagle275, I can't understand how the following statements can be compiled:
dGrid.Cols[i],AllowMoving(false); // columns remain in order
dGrid.Cols[i].AllowSizing(true); // user and program can change width of columns

AllowMoving and AllowSizing are column properties, and the correct syntax must be
dGrid.Cols[i].AllowMoving = false; // columns remain in order
dGrid.Cols[i].AllowSizing = true; // user and program can change width of columns


And one more tip for faster and simpler coding. The column collection provides you with an iterator you can use with the foreach loop, and your loop by columns above can be rewritten like this
foreach (iGCol col in dGrid.Cols){
.....
   col.AllowMoving = false;
   col.AllowSizing = true;
   col.MinWidth = col.Width;
   col.AutoWidth(true);
}


Feel free to continue this discussion and ask other related questions here.
eagle275
2020-06-12T11:59:23Z
in all honesty I would "divide" that setting ... in my eyes there is no reason to restrict the programmer
Why not allow changing it by program while restrict the user from fiddling with it - similar to AllowMoving - which has no side-effects
eagle275
2020-06-12T13:49:11Z
regarding the syntax - I had to retype code from another pc - maybe I mistyped those properties - as they work as intended I think they are written like your advice^^

and the iterator - would be neat but you cant use it to iterate over 2 different arrays (collections) at the same time ..

the .... in the for-loop contains code that looks in a different array if the user has set column widths (used by another developer who received specific requests how data is to be displayed) - so I use the looping variable i to step into 2 arrays

Igor/10Tec
2020-06-12T14:54:34Z
Originally Posted by: eagle275 

in all honesty I would "divide" that setting ... in my eyes there is no reason to restrict the programmer
Why not allow changing it by program while restrict the user from fiddling with it - similar to AllowMoving - which has no side-effects


Deep in my soul I agree with that. And similar settings must work the same way in the corresponding methods. I am thinking what to do with this and whether to enhance this in iGrid.NET X the way you suggested. Thank you for pointing this out!
abraXus
2020-06-13T04:48:18Z
Originally Posted by: Igor/10Tec 



eagle275 & abraxUs: Do you think it would be better not to check the AllowSizing setting if we call the AutoWidth() method for a column or the whole column collection? As I remember (but I may be wrong), there were cases when developers wanted to exclude some columns from processing when they called Cols.AutoWidth(). That's why we implemented the behavior we have now. But if you think it's more natural not to check this status in AutoWidth(), we could think about implementing this change in the forthcoming release of iGrid.NET X. Let me also ask other developers.



I wouldn't want to make any suggestion that affects how it has always worked, as I wouldn't want to force other developers to change their code. Instead, might I suggest some additional properties that can be used in addition to the current ones?

For example, the default grid control has a property called AllowUserToResizeColumns that can be set to False, disabling the that ability for the user, but the columns can still be sized/auto-sized using other programmatic methods. With something like that and a default setting of True (for the original functionality), it could also be set to False (with the normal AllowSizing property set to True), which would preserve existing functionality while also providing the functionality I would expect, coming from the world of the default grid control.

The other option I can think of would be a second AutoWidth method that would ignore the AllowSizing property.
Or maybe an optional boolean argument for this method that will tell it to include columns that have AllowSizing set to False?

That is my 2 cents, for what it's worth. I hope that makes sense, and if not, it should hopefully give you somewhat of an idea of what I am thinking.