Columns in MultiColumn ComboBox
Hi,
Is there a way to control the visible columns and their oder in MultiColumn ComboBox?
In another word, how to selectively show columns in MultiColumn ComboBox?
Thanks.
Q
Is there a way to control the visible columns and their oder in MultiColumn ComboBox?
In another word, how to selectively show columns in MultiColumn ComboBox?
Thanks.
Q
SIGN IN To post a reply.
9 Replies
QS
Qingde Shi
June 1, 2007 06:00 PM UTC
Anyone has any ideas?
>Hi,
Is there a way to control the visible columns and their oder in MultiColumn ComboBox?
In another word, how to selectively show columns in MultiColumn ComboBox?
Thanks.
Q
>Hi,
Is there a way to control the visible columns and their oder in MultiColumn ComboBox?
In another word, how to selectively show columns in MultiColumn ComboBox?
Thanks.
Q
MU
Murugan
Syncfusion Team
June 1, 2007 09:28 PM UTC
Hi Q,
1. We could hide a particular column of the MultiColumnComboBox using the following ways.
MultiColumnComboBox1.ListBox.Grid.Cols.Hidden(2) = True [or]
MultiColumnComboBox1.ListBox.Grid.HideCols(2) = True
2. We could change the order of the columns by handling the Grid_PrepareViewStyleInfo event.
[Code]
void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.ColIndex == 1)
{
GridControl grid = sender as GridControl;
e.Style.Text = grid.Model[e.RowIndex, 2].Text;
}
else if (e.ColIndex == 2)
{
GridControl grid = sender as GridControl;
e.Style.Text = grid.Model[e.RowIndex, 1].Text;
}
}
[Sample]
http://websamples.syncfusion.com/samples/Tools.Windows/F61776/Main.htm
Please refer to this and let me know if it helps you.
Thank you for your interest in Syncfusion products.
Regards,
Murugan P.S
1. We could hide a particular column of the MultiColumnComboBox using the following ways.
MultiColumnComboBox1.ListBox.Grid.Cols.Hidden(2) = True [or]
MultiColumnComboBox1.ListBox.Grid.HideCols(2) = True
2. We could change the order of the columns by handling the Grid_PrepareViewStyleInfo event.
[Code]
void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.ColIndex == 1)
{
GridControl grid = sender as GridControl;
e.Style.Text = grid.Model[e.RowIndex, 2].Text;
}
else if (e.ColIndex == 2)
{
GridControl grid = sender as GridControl;
e.Style.Text = grid.Model[e.RowIndex, 1].Text;
}
}
[Sample]
http://websamples.syncfusion.com/samples/Tools.Windows/F61776/Main.htm
Please refer to this and let me know if it helps you.
Thank you for your interest in Syncfusion products.
Regards,
Murugan P.S
QS
Qingde Shi
June 2, 2007 12:50 AM UTC
Murugan,
Thanks. The problem is when binding a list to the MultiColumnComboBox, the order of columns seems random. the column names are known, How to get the column index from Column Name?
Thanks,
Q
>Hi Q,
1. We could hide a particular column of the MultiColumnComboBox using the following ways.
MultiColumnComboBox1.ListBox.Grid.Cols.Hidden(2) = True [or]
MultiColumnComboBox1.ListBox.Grid.HideCols(2) = True
2. We could change the order of the columns by handling the Grid_PrepareViewStyleInfo event.
[Code]
void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.ColIndex == 1)
{
GridControl grid = sender as GridControl;
e.Style.Text = grid.Model[e.RowIndex, 2].Text;
}
else if (e.ColIndex == 2)
{
GridControl grid = sender as GridControl;
e.Style.Text = grid.Model[e.RowIndex, 1].Text;
}
}
[Sample]
http://websamples.syncfusion.com/samples/Tools.Windows/F61776/Main.htm
Please refer to this and let me know if it helps you.
Thank you for your interest in Syncfusion products.
Regards,
Murugan P.S
Thanks. The problem is when binding a list to the MultiColumnComboBox, the order of columns seems random. the column names are known, How to get the column index from Column Name?
Thanks,
Q
>Hi Q,
1. We could hide a particular column of the MultiColumnComboBox using the following ways.
MultiColumnComboBox1.ListBox.Grid.Cols.Hidden(2) = True [or]
MultiColumnComboBox1.ListBox.Grid.HideCols(2) = True
2. We could change the order of the columns by handling the Grid_PrepareViewStyleInfo event.
[Code]
void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.ColIndex == 1)
{
GridControl grid = sender as GridControl;
e.Style.Text = grid.Model[e.RowIndex, 2].Text;
}
else if (e.ColIndex == 2)
{
GridControl grid = sender as GridControl;
e.Style.Text = grid.Model[e.RowIndex, 1].Text;
}
}
[Sample]
http://websamples.syncfusion.com/samples/Tools.Windows/F61776/Main.htm
Please refer to this and let me know if it helps you.
Thank you for your interest in Syncfusion products.
Regards,
Murugan P.S
JA
JayaLakshmi
Syncfusion Team
June 4, 2007 01:07 PM UTC
Hi Q,
You can get the column index from column name using the following code snippet.
this.multiColumnComboBox1.ListBox.Grid.PrepareViewStyleInfo+=new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
void Grid_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = sender as GridControl;
int colIndex = grid.Model.NameToColIndex("LongName");
}
You can also refer the sample in the below location.
http://websamples.syncfusion.com/samples/Tools.Windows/F61776/main.htm
Kindly let me know if this helps.
Regards,
Jaya
You can get the column index from column name using the following code snippet.
this.multiColumnComboBox1.ListBox.Grid.PrepareViewStyleInfo+=new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
void Grid_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = sender as GridControl;
int colIndex = grid.Model.NameToColIndex("LongName");
}
You can also refer the sample in the below location.
http://websamples.syncfusion.com/samples/Tools.Windows/F61776/main.htm
Kindly let me know if this helps.
Regards,
Jaya
QS
Qingde Shi
June 4, 2007 03:02 PM UTC
Jaya,
This is helpful. Now I know how to get column index from its name.
However, I am still having difficulty for arranging the column orders in the MultiColumn ComboBox.
What Murugan said in the previous reply generated exceptions when column type is different. like switch text from string column to int column.
I also tried Grid.Model.Cols.MoveRange method, but no impact at all.
So I still need your help.
Thanks.
Q
>Hi Q,
You can get the column index from column name using the following code snippet.
this.multiColumnComboBox1.ListBox.Grid.PrepareViewStyleInfo+=new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
void Grid_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = sender as GridControl;
int colIndex = grid.Model.NameToColIndex("LongName");
}
You can also refer the sample in the below location.
http://websamples.syncfusion.com/samples/Tools.Windows/F61776/main.htm
Kindly let me know if this helps.
Regards,
Jaya
This is helpful. Now I know how to get column index from its name.
However, I am still having difficulty for arranging the column orders in the MultiColumn ComboBox.
What Murugan said in the previous reply generated exceptions when column type is different. like switch text from string column to int column.
I also tried Grid.Model.Cols.MoveRange method, but no impact at all.
So I still need your help.
Thanks.
Q
>Hi Q,
You can get the column index from column name using the following code snippet.
this.multiColumnComboBox1.ListBox.Grid.PrepareViewStyleInfo+=new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
void Grid_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = sender as GridControl;
int colIndex = grid.Model.NameToColIndex("LongName");
}
You can also refer the sample in the below location.
http://websamples.syncfusion.com/samples/Tools.Windows/F61776/main.htm
Kindly let me know if this helps.
Regards,
Jaya
JA
JayaLakshmi
Syncfusion Team
June 6, 2007 04:19 AM UTC
Hi Q,
You can achieve the reordering of the columns by storing the column information in a Hashtable and by handling Grid_PrepareViewStyleInfo event.
Here is the code snippet.
this.multiColumnComboBox1.ListBox.Grid.PrepareViewStyleInfo+=new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
Hashtable hash = new Hashtable();
void Grid_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = sender as GridControl;
if (hash.Contains(e.ColIndex))
{
if (hash[e.ColIndex] != null)
{
e.Style.CellValueType = grid[e.RowIndex, int.Parse(hash[e.ColIndex].ToString())].CellValueType;
e.Style.Text = grid[e.RowIndex, int.Parse(hash[e.ColIndex].ToString())].Text;
}
}
}
Please refer the modified sample in the below location and let me know if you have any other questions.
http://websamples.syncfusion.com/samples/Tools.Windows/F61776_1/main.htm
Thanks for your patience.
Regards,
Jaya
QS
Qingde Shi
June 6, 2007 02:41 PM UTC
Jaya,
Thanks. the CellValueType did the trick, though when switching multiple columns, there needs more logic than a simple hash table.
Not trying to be picky, however, how do you get the column width switched as well?
Thanks,
Q
>
Hi Q,
You can achieve the reordering of the columns by storing the column information in a Hashtable and by handling Grid_PrepareViewStyleInfo event.
Here is the code snippet.
this.multiColumnComboBox1.ListBox.Grid.PrepareViewStyleInfo+=new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
Hashtable hash = new Hashtable();
void Grid_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = sender as GridControl;
if (hash.Contains(e.ColIndex))
{
if (hash[e.ColIndex] != null)
{
e.Style.CellValueType = grid[e.RowIndex, int.Parse(hash[e.ColIndex].ToString())].CellValueType;
e.Style.Text = grid[e.RowIndex, int.Parse(hash[e.ColIndex].ToString())].Text;
}
}
}
Please refer the modified sample in the below location and let me know if you have any other questions.
http://websamples.syncfusion.com/samples/Tools.Windows/F61776_1/main.htm
Thanks for your patience.
Regards,
Jaya
Thanks. the CellValueType did the trick, though when switching multiple columns, there needs more logic than a simple hash table.
Not trying to be picky, however, how do you get the column width switched as well?
Thanks,
Q
>
Hi Q,
You can achieve the reordering of the columns by storing the column information in a Hashtable and by handling Grid_PrepareViewStyleInfo event.
Here is the code snippet.
this.multiColumnComboBox1.ListBox.Grid.PrepareViewStyleInfo+=new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
Hashtable hash = new Hashtable();
void Grid_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = sender as GridControl;
if (hash.Contains(e.ColIndex))
{
if (hash[e.ColIndex] != null)
{
e.Style.CellValueType = grid[e.RowIndex, int.Parse(hash[e.ColIndex].ToString())].CellValueType;
e.Style.Text = grid[e.RowIndex, int.Parse(hash[e.ColIndex].ToString())].Text;
}
}
}
Please refer the modified sample in the below location and let me know if you have any other questions.
http://websamples.syncfusion.com/samples/Tools.Windows/F61776_1/main.htm
Thanks for your patience.
Regards,
Jaya
JA
JayaLakshmi
Syncfusion Team
June 7, 2007 12:11 PM UTC
Hi Q,
Thanks for the update.
You can handle
MultiColumnComboBox.ListBox.Grid.QueryColWidth event to control the width of columns in a MultiColumnComboBox.
Kindly elaborate your requirement if I misunderstood it.
Thanks,
Jaya
QS
Qingde Shi
June 7, 2007 04:42 PM UTC
Hi Jaya,
Thank you for all your help.
instead of controling the looks of dropdown after DataSource was set, I took another approach, wrapping the datasouce, so the Dropdown would show the desired looks.
Thanks again.
Q
>
Hi Q,
Thanks for the update.
You can handle
MultiColumnComboBox.ListBox.Grid.QueryColWidth event to control the width of columns in a MultiColumnComboBox.
Kindly elaborate your requirement if I misunderstood it.
Thanks,
Jaya
Thank you for all your help.
instead of controling the looks of dropdown after DataSource was set, I took another approach, wrapping the datasouce, so the Dropdown would show the desired looks.
Thanks again.
Q
>
Hi Q,
Thanks for the update.
You can handle
MultiColumnComboBox.ListBox.Grid.QueryColWidth event to control the width of columns in a MultiColumnComboBox.
Kindly elaborate your requirement if I misunderstood it.
Thanks,
Jaya
SIGN IN To post a reply.
- 9 Replies
- 3 Participants
-
QS Qingde Shi
- Jun 1, 2007 01:15 PM UTC
- Jun 7, 2007 04:42 PM UTC