Hi ,
oCombo.DisplayLayout.Grid.Rows[0].Cells[0].Column.PerformAutoResize();
On this code I get a runtime error telling me the index is outside the bounderies.
Any help is appreciated!
regards,
Erik
Hi Erik,
How about:
ultraCombo1.DisplayLayout.Bands[0].Columns[0].PerformAutoResize();
Andy.
Hi Andy,
Thanks for your answer.
Any other suggestions?
Thanks Vince and Mike.
The hint Vince submitted did the trick get rid of the runtime error and the addition of Mike resulted in the wanted behaviour.
Thanks for great support and a great product!
Also, you probably need to call the overload of PerformAutoResize that takes an enum and specify AllRowsInBand. Otherwise, you are sizing based only on the visible rows and in this case, there will be no visible rows until the list is dropped down at least once.
cPortUser said:It is not called in an event, it is called during initializing the (datadriven) form.
My first suggestion is to move this call until after you've added the control to the appropriate Controls collection:
// oCombo.DisplayLayout.Bands[0].Columns[0].PerformAutoResize();oCombo.TabIndex = Counter;base.Controls.Add(oCombo);oCombo.DisplayLayout.Bands[0].Columns[0].PerformAutoResize();
If that still isn't late enough, move the call to your Form_Shown event handler.
Vince McDonald"]In what event are you calling this function?
It is not called in an event, it is called during initializing the (datadriven) form.
Vince McDonald"]Additionally, is the combo's DataSource set before you call this method?
Yes it is. See my code below. Any suggestions?
UltraCombo oCombo = this.AddUltraCombo(cName, cSqlCOm, dt);oCombo.Size = new Size(wEditWidth, wEditHeight * 5); oCombo.Location = new Point((wLeft + wTextWidth) + wVerGap, wPixelHeight + 7);oCombo.ReadOnly = true;oCombo.DisplayLayout.Bands[0].Columns[0].PerformAutoResize();oCombo.TabIndex = Counter;base.Controls.Add(oCombo);
{
Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance();Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance();Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance();Infragistics.Win.UltraWinGrid.UltraCombo ultraCombo1 = new Infragistics.Win.UltraWinGrid.UltraCombo();((System.ComponentModel.ISupportInitialize)(ultraCombo1)).BeginInit();ultraCombo1.CharacterCasing = System.Windows.Forms.CharacterCasing.Normal;appearance5.BackColor = System.Drawing.Color.White;ultraCombo1.DisplayLayout.Appearance = appearance5;ultraCombo1.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.True;appearance6.BackColor = System.Drawing.Color.Transparent;ultraCombo1.DisplayLayout.Override.CardAreaAppearance = appearance6;appearance7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(89)))), ((int)(((byte)(135)))), ((int)(((byte)(214)))));appearance7.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(7)))), ((int)(((byte)(59)))), ((int)(((byte)(150)))));appearance7.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;appearance7.FontData.BoldAsString = "True";appearance7.FontData.Name = "Arial";appearance7.FontData.SizeInPoints = 10F;appearance7.ForeColor = System.Drawing.Color.White;appearance7.ThemedElementAlpha = Infragistics.Win.Alpha.Transparent;ultraCombo1.DisplayLayout.Override.HeaderAppearance = appearance7;ultraCombo1.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortSingle;ultraCombo1.DisplayLayout.Override.RowFilterAction = Infragistics.Win.UltraWinGrid.RowFilterAction.HideFilteredOutRows;appearance8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(89)))), ((int)(((byte)(135)))), ((int)(((byte)(214)))));appearance8.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(7)))), ((int)(((byte)(59)))), ((int)(((byte)(150)))));appearance8.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;ultraCombo1.DisplayLayout.Override.RowSelectorAppearance = appearance8;appearance9.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(251)))), ((int)(((byte)(230)))), ((int)(((byte)(148)))));appearance9.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(149)))), ((int)(((byte)(21)))));appearance9.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;ultraCombo1.DisplayLayout.Override.SelectedRowAppearance = appearance9;ultraCombo1.DisplayStyle = Infragistics.Win.EmbeddableElementDisplayStyle.Default;ultraCombo1.Location = new System.Drawing.Point(92, 64);ultraCombo1.Name = cName;ultraCombo1.Size = new System.Drawing.Size(100, 22);ultraCombo1.TabIndex = 0;SqlCommand oCommand = new SqlCommand();oCommand.CommandText = cSql;oCommand.Connection = this.oConn;SqlDataAdapter oDataAdapter = new SqlDataAdapter();oDataAdapter.SelectCommand = oCommand;DataTable oTable = new DataTable();oDataAdapter.Fill(oTable);ultraCombo1.DataSource = oTable;ultraCombo1.ValueMember = oTable.Columns[0].ColumnName;ultraCombo1.DataBindings.Add(new Binding("Value", dt, cName));ultraCombo1.AfterCloseUp += new EventHandler(ultraCombo1_ValueChanged);ultraCombo1.ValueChanged += new EventHandler(ultraCombo1_ValueChanged);((System.ComponentModel.ISupportInitialize)(ultraCombo1)).EndInit();return ultraCombo1;
}
In what event are you calling this function?
Andy Jones said:ultraCombo1.DisplayLayout.Bands[0].Columns[0].PerformAutoResize();
Additionally, is the combo's DataSource set before you call this method?
The exception means that there was either a problem retrieving the band (unlikely since the combo auto-generates band 0) or the column.