|
there are several ways to control the formatting of a cell, a row, a column, in a DataGridView.
Look for DefaultCellStyle in each of those, and/or use the DataGridView.CellFormatting event.
Warning: background coloring may malfunction on empty cells; you might read my CP Vanity[^] article.
|
|
|
|
|
Good Day All
i have Successfully binded the Telerik Schedular from Objects and its looking Good. Now i have to Bind the same results but in hierachial form. Please note that i am using Telerik Grid and the implementation is the same as asp.net Gridview. i need someone to Guide me to do a hierachy grid from objects , please if you send an example code , add comments so that i can understand the logic.
private void BindViewer()
{
VS.ViewerService obj = new VS.ViewerService();
String SessionKey = obj.newSession();
DateTime Date1 = Convert.ToDateTime("1980-01-01");
DateTime Date2 = Convert.ToDateTime("2012-12-31");
VS.extract extract = obj.getObjects(SessionKey, "Butt", Date1, false, Date2, false, "", "");
try
{
RadPanelBar1.Items.Clear();
RadScheduler1.Appointments.Clear();
int Len = extract.set.Length;
for (int i = 0; i < Len; i++)
{
VS.vertex value = extract.set[i];
String PanelClass = value.meta;
PanelClass = PanelClass.Replace(Remstr, "");
PanelClass = PanelClass.Replace(Remstr2, "");
Appointment app = null;
if (value.atom != null)
{
RadPanelItem pane = RadPanelBar1.Items.FindItemByText(PanelClass);
if (pane == null)
{
RadPanelItem nwpane = new Telerik.Web.UI.RadPanelItem(PanelClass);
RadPanelItem nwpaneSpliter = new Telerik.Web.UI.RadPanelItem(PanelClass);
nwpaneSpliter.IsSeparator = true;
RadPanelBar1.Items.Add(nwpane);
pane = nwpane;
}
if (value.meta == "za.co.abacus.C_EVENT")
{
app = new Appointment();
}
int atomLen = value.atom.Length;
for (int j = 0; j < atomLen; j++)
{
VS.atom atm = value.atom[j];
if (atm.meta.Contains("za.co.reactor.A_LABEL"))
{
RadPanelItem NewItem = new RadPanelItem(atm.content);
pane.Items.Add(NewItem);
if (app != null)
{
app.Subject = atm.content;
app.Description = atm.content;
app.ID = value.key;
}
}
if (app != null && atm.meta.Contains("za.co.abacus.C_EVENT"))
{
app.ID = atm.content;
}
if (app != null && atm.meta.Contains("za.co.reactor.A_HORIZON"))
{
app.Start = Convert.ToDateTime(atm.content);
}
if (app != null && atm.meta.Contains("za.co.reactor.AA_HORIZON"))
{
app.End = Convert.ToDateTime(atm.content);
}
if (app != null && atm.meta.Contains("za.co.reactor.A_TEXT"))
{
app.Description = atm.content;
}
if (app != null && atm.meta.Contains("za.co.reactor.A_TEXT"))
{
app.RecurrenceRule = atm.content;
}
if (app != null && app.End > app.Start)
{
RadScheduler1.DataStartField = app.Start.ToString();
RadScheduler1.DataSubjectField = app.Subject.ToString();
RadScheduler1.DataEndField = app.End.ToString();
RadScheduler1.DataKeyField = app.ID.ToString();
RadScheduler1.SelectedView = SchedulerViewType.MonthView;
RadScheduler1.SelectedDate = app.Start;
SlidingZone1.ExpandedPaneId = "RadSlidingPane1";
}
}
}
}
}
catch (ApplicationException ex)
{
}
finally
{
obj.closeSession(SessionKey);
}
}
Now with the same results i want to bind a Hierachy Grid as it Shows in my attached image. I am using EAV that means the is no Fixed Column name, so the Binding of the Grid Should be Dynamically.
Thank you
http://www.telerik.com/ClientsFiles/211914_hierachygridview.JPG[^]
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
|
I'm just attempting to form a mind meld with your source code...
Nope, it's not working. Please go to Visual Studio menu: "Tools...Options...Source Control...Plug In selection" and enable "Vulcan SCMM" module. Oh, and don't close VS or turn your computer off!
Alternatively, post a relevant code fragment here, and save us all that mental effort.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
|
No - not going to look at that either! Try changing the "inline code" to "code block" it preserves the formatting.
Inline code:
if (dataFromClient == "listClients")<br />
{<br />
dataFromClient = "";<br />
<br />
foreach (DictionaryEntry Item in clientsList)<br />
{<br />
dataFromClient += Item.Key + "---" + ((TcpClient)Item.Value).Client.RemoteEndPoint.ToString() + "+++";<br />
}<br />
<br />
dataToClient = clNo;<br />
}<br />
Code block:
if (dataFromClient == "listClients")
{
dataFromClient = "";
foreach (DictionaryEntry Item in clientsList)
{
dataFromClient += Item.Key + "---" + ((TcpClient)Item.Value).Client.RemoteEndPoint.ToString() + "+++";
}
dataToClient = clNo;
} See what I mean? You can get away with it for a couple of lines, but with a whole class it is way too much effort to read!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
|
I have edited the format....
Regards.
|
|
|
|
|
Ok, well done! It is now readable.
Did you mean you don't get the "You have left the session" message in the Disconnect method?
If so, then it would probably help to reference it at some point. At present, it just sits there, feeling lonely and unwanted as nobody calls it.
All you do is sit in a pair of loops - one in main where you try top start threads like crazy, and the other in doChat where you loop until an error occurs, print the error, and then loop some more.
I think you need to sit down and look at what you are trying to achieve in a lot more detail, and then try to start again from scratch.
BTW: Look at your errors listing when you compile this - you are getting a warning that TcpLister(int) is obsolete - take note of warnings, there aren't there for fun!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
OriginalGriff wrote: you are getting a warning that TcpLister(int) is obsolete
OriginalGriff wrote: it just sits there, feeling lonely and unwanted as nobody calls it.
Maybe some of the code has fled before, while you were practicing your mind melting voodoo.
|
|
|
|
|
I thought I was safe - aren't you off playing chess?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
No one is ever safe from my bot brothers and sisters, and no, you won't be able to tell us apart.
But you're right, Luc is at the tournament as we speak.
|
|
|
|
|
If I can't tell the difference between the brothers and the sisters, I do not want to meet the family!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
ok i try.
Thanks for immediate response.
Regards.
|
|
|
|
|
Hi,
I have a gridview and my last column is tpe of button,
i'm trying to get the value from the button that was pressed.
I tryied this line with RowCommand Event-
string value=myGrid.Rows[int.Parse(e.CommandArgument.ToString())].Cells[1].Text;
here i get's empty value.
Can someone please help me?
|
|
|
|
|
|
|
txtcode.Text = dataGridView1.Rows[j].Cells[i].Value.ToString();
|
|
|
|
|
|
You might want to ask this question in the WPF forum or in Quick Answers (but not both... cross-posting is frowned upon here). My guess, however, is that there is an event for when the video stops playing. Hook up to that event and detect if the video played back fully (i.e., that the user didn't manually stop it) using the Position.TotalSeconds property (if that's a real property). If you can't find any sort of event like that (though I'm sure one must exist), then I'd say just keep polling in a loop or on a timer to see if the TotalSeconds has been reached yet and then play the next item. You could also create a timer that assumes the video plays instantly and waits for the total duration of the video, then starts the next video and repeats that process until it reaches the last video.
|
|
|
|
|
All, I apologize if this has been answered somewhere in the forum already. I've searched for a couple of hours here and the general web and haven't found a suitable answer.
I simply want to output an RTF file that contains hyperlinks (URL) but shows ONLY the text for that link, not both the text and the full URL.
Here's brief code snippet that does NOT work as expected:
richTextBox1.LoadFile(inputFile, RichTextBoxStreamType.RichText);
richTextBox1.SaveFile(outputFile, RichTextBoxStreamType.RichText);
This snippet simply reads in an RTF file into a RichTextBox control and saves it back out (This is not what I'm actually trying to do in the long run, I just wanted to isolate the issue for clarity).
When I open the files in MS Word:
The original file (inputFile) has the text: "Bug# 137". This text is a hyperlink and all you see is the text and you could click it and go to the corresponding web page.
The "copied" version of the file contains the text: "Bug# 135 <http: www.google.com="">". This text is blue, and is underlined. Yet there are 2 things wrong with it:
1) It lists the entire URL, not just the text ("Bug# 135")
2) It is not an actual link, just blue, underlined text.
I'm using VS 2010. I have explicitly set "DetectURLs" boolean property, though I believe it's set to "true" by default.
Any assistance with this "gnawing" issue would be greatly appreciated.
|
|
|
|
|
Hi Guys. I have been trying to resolve an error I keep getting. I have an app with a number of forms. Most of the forms has a datagridview with edit and delete buttons. Most of them work fine but on two of the most simpler forms it just for some reason doesn't seem to work. Whenever I click on any of the column I get the following error:
Index out of range. must be non-negative and less than the size of the collection. Parameter name : index.
The same code I am using here works on other forms but not on this one.
Below is the code I am using.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int currentRow = int.Parse(e.RowIndex.ToString());
int rowint = 0;
dt.Clear();
try
{
conn.Open();
string taskstring = dataGridView1[0, currentRow].Value.ToString();
rowint = int.Parse(taskstring);
if (dataGridView1.Columns[e.ColumnIndex] == deleteButton && currentRow >= 0)
{
string queryDeleteString = "DELETE FROM tblTasks where TaskCode = " + rowint + "";
OleDbCommand sqlDelete = new OleDbCommand();
sqlDelete.CommandText = queryDeleteString;
sqlDelete.Connection = conn;
sqlDelete.ExecuteNonQuery();
}
else if (dataGridView1.Columns[e.ColumnIndex] == editButton && currentRow >= 0)
{
string updatestring = "Select TaskCode, TaskName, TaskDescription FROM tblTasks WHERE TaskCode = " + rowint + "";
string taskname = dataGridView1[dataGridView1.Columns["TaskName"].Index, currentRow].Value.ToString();
string description = dataGridView1[dataGridView1.Columns["TaskDescription"].Index, currentRow].Value.ToString();
OleDbDataAdapter da = new OleDbDataAdapter(updatestring, conn);
OleDbCommandBuilder cmdb = new OleDbCommandBuilder(da);
da.Update(dt);
string update = "UPDATE tblTasks SET TaskName = '" + taskname + "', TaskDescription = '" + description + "' WHERE TaskCode = " + rowint + "";
da.UpdateCommand = conn.CreateCommand();
da.UpdateCommand.CommandText = update;
da.UpdateCommand.ExecuteNonQuery();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
getData();
}
}
Can anybody see anything here that would cause the problem? As mentioned, the same code works on other forms that have much more columns and data on it. Only two fo the forms don't seem to work with this code.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Which line is throwing the error?
Is this handler attached to dataGridView1?
Why are you using Parse?
int currentRow = int.Parse(e.RowIndex.ToString()); DataGridViewCellEventArgs.RowIndex is an int already...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Hi Griff.
1) Yes, it is attacheched to a dataGridView.
2) How would you write that bit of code? In order to get the int I need to Parse the RowIndex to int. If you can show me how else to get it then I'll try it.
Like I mentioned, It workes on all the other dataGridViews fine, except for two of them and they all use the exact same code!
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Ok, I have done two things.
The error seems to come in here:
string taskstring = dataGridView1[0, currentRow].Value.ToString();
I have also re-writtent the currentRow as this which seems to work:
int currentRow = e.RowIndex;
So, with the error narrowed down, why do you think it does this on this form and not on the other?
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|