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.
Unfortunately, activation email could not send to your email. Please try again.

Columns in MultiColumn ComboBox

Thread ID:

Created:

Updated:

Platform:

Replies:

61776 Jun 1,2007 09:15 AM Jun 7,2007 12:42 PM Windows Forms 9
loading
Tags: Tools
Qingde Shi
Asked On June 1, 2007 09:15 AM

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

Qingde Shi
Replied On June 1, 2007 02:00 PM

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

Murugan [Syncfusion]
Replied On June 1, 2007 05:28 PM

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

Qingde Shi
Replied On June 1, 2007 08:50 PM

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

JayaLakshmi [Syncfusion]
Replied On June 4, 2007 09:07 AM

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

Qingde Shi
Replied On June 4, 2007 11:02 AM

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

JayaLakshmi [Syncfusion]
Replied On June 6, 2007 12:19 AM


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

Qingde Shi
Replied On June 6, 2007 10:41 AM

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

JayaLakshmi [Syncfusion]
Replied On June 7, 2007 08:11 AM


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

Qingde Shi
Replied On June 7, 2007 12:42 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;