Hi, I need help.
I have a grid, I need to open a different form for each column in my grid, in doubleclik event.
I have now the code for catch the name of the current column in a variable, but... How do I do for compare it with the name of each column.
something like this:
If variablecurrentcolumn = "Column1"
open frm1
if variablecurrentcolumn = "column2"
open form2
Thank you :)
This is my code for catch column:
string sColumna = e.Cell.Column.Header.Caption;
and I have this for compare variable with the column name:
if (sColumna == Convert.ToString(e.Cell.Column.Header.Caption["creditos"])) { frmMovCreditos frmMovCreditos = new frmMovCreditos(); this.MuestraFormaModal(frmMovCreditos); }
But it has a error with the arguments... string.this[int] arguments not valid.
May someone help me?
Hi,
I'm having a hard time understand what you are trying to do. Typically, you would identify a column by it's Key, rather than it's header caption. The caption is just the text the user sees, so you might decide to change this in the future and you wouldn't want to re-write your code if you do.
Anyway, the code you have here is raising an Exception because you are trying to use an indexer on a string property (Caption). This doesn't make any sense and - like I said - I'm having trouble understanding what you are trying to do or why you would do this. You already have the column object. So why are you comparing it's column caption to itself?
Yes! my question was a very basic thing.
And Thank You.
Sorry, but I still don't understand what the issue is. It sounds like you are asking a very basic question about how to program in C# - are you asking how to write code that compares a string?
private void ultraGrid1_DoubleClickCell(object sender, DoubleClickCellEventArgs e) { switch (e.Cell.Column.Key) { case "Column 0": // show form 0 break; case "Column 1": // show form 1 break; case "Column 2": // show form 2 break; case "Column 3": // show form 3 break; } }
Ok, I Have a Grid with 10 columns.
I want that when I do doubleclick in for example "columnZ" ... Open the formZ. If I do doubleclik in "columnG"... open the "formG"
ok, I have now the caption of the column, but I don't know how do the "IF" for each condition.
for example